def PortAllEntities(datastore_path):
 previous_stub = apiproxy_stub_map.apiproxy.GetStub('datastore_v3')
 try:
  app_id = os.environ['APPLICATION_ID']
  apiproxy_stub_map.apiproxy = apiproxy_stub_map.APIProxyStubMap()
  datastore_stub = datastore_file_stub.DatastoreFileStub(app_id, datastore_path, trusted=True)
  apiproxy_stub_map.apiproxy.RegisterStub('datastore_v3', datastore_stub)
  entities = FetchAllEntitites()
  sqlite_datastore_stub = datastore_sqlite_stub.DatastoreSqliteStub(app_id, (datastore_path + '.sqlite'), trusted=True)
  apiproxy_stub_map.apiproxy.ReplaceStub('datastore_v3', sqlite_datastore_stub)
  PutAllEntities(entities)
  sqlite_datastore_stub.Close()
 finally:
  apiproxy_stub_map.apiproxy.ReplaceStub('datastore_v3', previous_stub)
 shutil.copy(datastore_path, (datastore_path + '.filestub'))
 _RemoveFile(datastore_path)
 shutil.move((datastore_path + '.sqlite'), datastore_path)

def PortAllEntities ( datastore_path ) : previous_stub = apiproxy_stub_map . apiproxy . GetStub ( 'datastore_v3' ) try : app_id = os . environ [ 'APPLICATION_ID' ] apiproxy_stub_map . apiproxy = apiproxy_stub_map . APIProxyStubMap ( ) datastore_stub = datastore_file_stub . DatastoreFileStub ( app_id , datastore_path , trusted = True ) apiproxy_stub_map . apiproxy . RegisterStub ( 'datastore_v3' , datastore_stub ) entities = FetchAllEntitites ( ) sqlite_datastore_stub = datastore_sqlite_stub . DatastoreSqliteStub ( app_id , ( datastore_path + '.sqlite' ) , trusted = True ) apiproxy_stub_map . apiproxy . ReplaceStub ( 'datastore_v3' , sqlite_datastore_stub ) PutAllEntities ( entities ) sqlite_datastore_stub . Close ( ) finally : apiproxy_stub_map . apiproxy . ReplaceStub ( 'datastore_v3' , previous_stub ) shutil . copy ( datastore_path , ( datastore_path + '.filestub' ) ) _RemoveFile ( datastore_path ) shutil . move ( ( datastore_path + '.sqlite' ) , datastore_path )
copies entities from a datastorefilestub to an sqlite stub .