def delete_project(self, project): # Check name if not is_valid_project_name(project.name): return None path = self._get_project_path(project.name) os.remove(path)
def save_project(self, project): # Check name if not is_valid_project_name(project.name): return None path = self._get_project_path(project.name) with open(path, 'w') as f: yaml.safe_dump(project.data, f)
def create_project(self, projectname, owner): # Check name if not is_valid_project_name(projectname): return None if self.get_project(projectname) is None: self.database.projects.insert({'name': projectname, 'owner': owner.userid}) return self.get_project(projectname)
def get_project(self, projectname): # Check name if not is_valid_project_name(projectname): return None project = self.database.projects.find_one({'name': projectname}) if project is not None: return Project(self.compmgr, self._decode_dict_keys(project))
def create_project(self, projectname, owner): # Check name if not is_valid_project_name(projectname): return None if self.get_project(projectname) is None: path = self._get_project_path(projectname) with open(path, 'w') as f: yaml.safe_dump({'name': projectname, 'owner': owner.userid}, f) return self.get_project(projectname)
def get_project(self, projectname): # Check name if not is_valid_project_name(projectname): return None path = self._get_project_path(projectname) if os.path.exists(path): with open(path, 'r') as f: return Project(self.compmgr, yaml.safe_load(f))
def create_project(self, projectname, owner): # Check name if not is_valid_project_name(projectname): return None if self.get_project(projectname) is None: self.database.projects.insert({ 'name': projectname, 'owner': owner.userid }) return self.get_project(projectname)