def create_empty_repo(path, name, description): repo_info_file = RepoDelegate.get_repo_info_path(path) content = { "name": name, "volume": 0, "description": description, "datetime": tools.get_time(), "subdirs": [] } tools.set_json_content(repo_info_file, content) return RepoDelegate(path)
def create_empty_catalog(path, name, description): catalog_info_file = CatalogDelegate.get_catalog_info_path(path) catalog_content = { "name": name, "volume": 0, "maxid": 0, "description": description, "datetime": tools.get_time(), "subdirs": [] } tools.set_json_content(catalog_info_file, catalog_content) signs_list_info_file = CatalogDelegate.get_signs_list_info_path(path) signs_list_content = {} tools.set_json_content(signs_list_info_file, signs_list_content) return CatalogDelegate(path)
def add_signs(self, signs_path, volume, provider, description): self._maxid += 1 id = self._maxid os.renames(signs_path, os.path.join(self._catalog_path, str(id))) self._volume += volume signs_list_info_file = CatalogDelegate.get_signs_list_info_path( self._catalog_path) signs_list_info = tools.get_json_content(signs_list_info_file) signs_list_info[id] = { 'volume': volume, 'provider': provider, 'description': description, 'datetime': tools.get_time() } tools.set_json_content(signs_list_info_file, signs_list_info)