def loadSavedProjects(self): """Load the savedProjects dictionary from the saved_projects.yml file. If the saved_projects.yml file is not existing, it is created with the "{paths: []}" value and the returned dictionnary is {paths: []}. :returns: the dictionary """ config = Config() try: with open( os.path.join(config.get_config_path(), 'saved_projects.yml'), 'r') as stream: try: if version.parse(yaml.__version__) > version.parse("5.1"): return yaml.load(stream, Loader=yaml.FullLoader) else: return yaml.load(stream) except yaml.YAMLError as exc: print(exc) except FileNotFoundError as exc: with open( os.path.join(config.get_config_path(), 'saved_projects.yml'), 'w') as stream: yaml.dump({'paths': []}, stream, default_flow_style=False) return {'paths': []}
def saveSavedProjects(self): """Saves the savedProjects dictionary to the saved_projects.yml file.""" config = Config() with (open(os.path.join(config.get_config_path(), 'saved_projects.yml'), 'w', encoding='utf8')) as configfile: yaml.dump(self.savedProjects, configfile, default_flow_style=False, allow_unicode=True)