def load(): """ If docs fail to load, new ones are created and saved. """ prefs_file_path = userfolders.get_config_dir() + PREFS_DOC recents_file_path = userfolders.get_config_dir() + RECENT_DOC global prefs, recent_projects try: prefs = utils.unpickle(prefs_file_path) except: prefs = EditorPreferences() with atomicfile.AtomicFileWriter(prefs_file_path, "wb") as afw: write_file = afw.get_file() pickle.dump(prefs, write_file) # Override deprecated preferences to default values. prefs.delta_overlay = True prefs.auto_play_in_clip_monitor = False prefs.empty_click_exits_trims = True prefs.quick_enter_trims = True prefs.remember_monitor_clip_frame = True try: recent_projects = utils.unpickle(recents_file_path) except: recent_projects = utils.EmptyClass() recent_projects.projects = [] with atomicfile.AtomicFileWriter(recents_file_path, "wb") as afw: write_file = afw.get_file() pickle.dump(recent_projects, write_file) # Remove non-existing projects from recents list remove_list = [] for proj_path in recent_projects.projects: if os.path.isfile(proj_path) == False: remove_list.append(proj_path) if len(remove_list) > 0: for proj_path in remove_list: recent_projects.projects.remove(proj_path) with atomicfile.AtomicFileWriter(recents_file_path, "wb") as afw: write_file = afw.get_file() pickle.dump(recent_projects, write_file) # Versions of program may have different prefs objects and # we may need to to update prefs on disk if user has e.g. # installed later version of Flowblade. current_prefs = EditorPreferences() if len(prefs.__dict__) != len(current_prefs.__dict__): current_prefs.__dict__.update(prefs.__dict__) prefs = current_prefs with atomicfile.AtomicFileWriter(prefs_file_path, "wb") as afw: write_file = afw.get_file() pickle.dump(prefs, write_file) print("prefs updated to new version, new param count:", len(prefs.__dict__))
def load(): """ If docs fail to load, new ones are created and saved. """ prefs_file_path = userfolders.get_config_dir() + PREFS_DOC recents_file_path = userfolders.get_config_dir() + RECENT_DOC global prefs, recent_projects try: f = open(prefs_file_path) prefs = pickle.load(f) except: prefs = EditorPreferences() write_file = file(prefs_file_path, "wb") pickle.dump(prefs, write_file) # Override deprecated preferences to default values. prefs.delta_overlay = True prefs.auto_play_in_clip_monitor = False prefs.empty_click_exits_trims = True prefs.quick_enter_trims = True prefs.remember_monitor_clip_frame = True try: f = open(recents_file_path) recent_projects = pickle.load(f) except: recent_projects = utils.EmptyClass() recent_projects.projects = [] write_file = file(recents_file_path, "wb") pickle.dump(recent_projects, write_file) # Remove non-existing projects from recents list remove_list = [] for proj_path in recent_projects.projects: if os.path.isfile(proj_path) == False: remove_list.append(proj_path) if len(remove_list) > 0: for proj_path in remove_list: recent_projects.projects.remove(proj_path) write_file = file(recents_file_path, "wb") pickle.dump(recent_projects, write_file) # Versions of program may have different prefs objects and # we may need to to update prefs on disk if user has e.g. # installed later version of Flowblade. current_prefs = EditorPreferences() if len(prefs.__dict__) != len(current_prefs.__dict__): current_prefs.__dict__.update(prefs.__dict__) prefs = current_prefs write_file = file(prefs_file_path, "wb") pickle.dump(prefs, write_file) print "prefs updated to new version, new param count:", len(prefs.__dict__)
def save(): """ Write out prefs and recent_projects files """ prefs_file_path = userfolders.get_config_dir() + PREFS_DOC recents_file_path = userfolders.get_config_dir() + RECENT_DOC write_file = file(prefs_file_path, "wb") pickle.dump(prefs, write_file) write_file = file(recents_file_path, "wb") pickle.dump(recent_projects, write_file)
def save(): """ Write out prefs and recent_projects files """ prefs_file_path = userfolders.get_config_dir()+ PREFS_DOC recents_file_path = userfolders.get_config_dir() + RECENT_DOC write_file = file(prefs_file_path, "wb") pickle.dump(prefs, write_file) write_file = file(recents_file_path, "wb") pickle.dump(recent_projects, write_file)
def save(): """ Write out prefs and recent_projects files """ prefs_file_path = userfolders.get_config_dir() + PREFS_DOC recents_file_path = userfolders.get_config_dir() + RECENT_DOC with atomicfile.AtomicFileWriter(prefs_file_path, "wb") as afw: write_file = afw.get_file() pickle.dump(prefs, write_file) with atomicfile.AtomicFileWriter(recents_file_path, "wb") as afw: write_file = afw.get_file() pickle.dump(recent_projects, write_file)
def remove_non_existing_recent_projects(): # Remove non-existing projects from recents list recents_file_path = userfolders.get_config_dir() + RECENT_DOC remove_list = [] for proj_path in recent_projects.projects: if os.path.isfile(proj_path) == False: remove_list.append(proj_path) if len(remove_list) > 0: for proj_path in remove_list: recent_projects.projects.remove(proj_path) write_file = file(recents_file_path, "wb") pickle.dump(recent_projects, write_file)
def remove_non_existing_recent_projects(): # Remove non-existing projects from recents list recents_file_path = userfolders.get_config_dir() + RECENT_DOC remove_list = [] for proj_path in recent_projects.projects: if os.path.isfile(proj_path) == False: remove_list.append(proj_path) if len(remove_list) > 0: for proj_path in remove_list: recent_projects.projects.remove(proj_path) write_file = file(recents_file_path, "wb") pickle.dump(recent_projects, write_file)