def export_usermessages_batch(input_path, output_path):
 with open(input_path, 'r') as input_file:
  output = ujson.loads(input_file.read())
 message_ids = [item['id'] for item in output['zerver_message']]
 user_profile_ids = set(output['zerver_userprofile_ids'])
 del output['zerver_userprofile_ids']
 realm = Realm.objects.get(id=output['realm_id'])
 del output['realm_id']
 output['zerver_usermessage'] = fetch_usermessages(realm, set(message_ids), user_profile_ids, output_path)
 write_message_export(output_path, output)
 os.unlink(input_path)

def export_usermessages_batch ( input_path , output_path ) : with open ( input_path , 'r' ) as input_file : output = ujson . loads ( input_file . read ( ) ) message_ids = [ item [ 'id' ] for item in output [ 'zerver_message' ] ] user_profile_ids = set ( output [ 'zerver_userprofile_ids' ] ) del output [ 'zerver_userprofile_ids' ] realm = Realm . objects . get ( id = output [ 'realm_id' ] ) del output [ 'realm_id' ] output [ 'zerver_usermessage' ] = fetch_usermessages ( realm , set ( message_ids ) , user_profile_ids , output_path ) write_message_export ( output_path , output ) os . unlink ( input_path )
as part of the system for doing parallel exports .