def load(recording_path): recording = None with open(recording_path, 'rb') as f: recording = loads(f.read()) return recording
def import_movesets(): for shared_path in glob(_SHARED_MOVESETS_GLOB_PATH): if os.path.isfile(shared_path): moveset = None with open(shared_path, 'rb') as mvs_file: moveset = loads(mvs_file.read()) save_imported_animations(moveset) #save the moveset if a moveset with its name doesn't already exist. If it does exist find a name that has yet to be saved by appending '(#)' where # is a number. existing_moveset = get_moveset(moveset.name) if existing_moveset == None: save_moveset(moveset) else: name_counter = 1 name = moveset.name while existing_moveset != None: name_counter += 1 moveset.name = name + "(" + str(name_counter) + ")" existing_moveset = get_moveset(moveset.name) save_moveset(moveset) #move the imported moveset to the imported folder to show that it has been completed shutil.move( shared_path, os.path.join( _IMPORTED_MOVESETS_DIR, os.path.split(shared_path)[1] ) )