def _update_extensions(): os.chdir(os.path.join(app.root_path, "tmp", "registry")) Popen(["git", "checkout", "stable"]).wait() Popen(['git', 'pull']).wait() src_path = os.path.join(app.root_path, "tmp", "registry", "extensions") for name in os.listdir(src_path): statusfile = open(os.path.join(src_path, name, 'status.yml'), 'r') statusdata = ymlload(statusfile) statusfile.close() if statusdata['approved']: status = statusdata['status'] metafile = open(os.path.join(src_path, name, 'data.yml'), 'r') metadata = ymlload(metafile) metafile.close() datafile = open(os.path.join(src_path, name, 'page.md'), 'r') extdata = datafile.read() datafile.close() row = db.Extension(name=metadata['name']) if not row: slug = Urlify()(metadata['name'])[0] rid = db.Extension.insert(name=metadata['name'], slug=slug) row = db.Extension(id=rid) row.update_record(status=status, author_name=metadata['author']['name'], author_email=metadata['author']['email'], description=metadata['description'], github=metadata['github'], pypi=metadata['pypi'], version=metadata['version'], website=metadata.get('website'), bugtracker=metadata['bugtracker'], license=metadata['license'], data=extdata) db.commit()
def config_from_yaml(self, filename, namespace=None): #: import configuration from yaml files rc = read_file(os.path.join(self.config_path, filename)) rc = ymlload(rc) c = self.config if namespace is None else self.config[namespace] for key, val in rc.items(): c[key] = dict_to_sdict(val)
def _load_source(self, path: Path, filename_prefix: bool = False): ext = path.suffix if ext == '.json': with path.open("rt", encoding=self._encoding) as f: data = json.loads(f.read()) elif ext in ['.yml', '.yaml']: with path.open("rt", encoding=self._encoding) as f: data = ymlload(f.read(), Loader=ymlLoader) else: raise RuntimeError(f'Invalid source format: {path}') prefix = filename_prefix and path.stem or None self._load_data(data, prefix)
def _update_extensions(): os.chdir(os.path.join(app.root_path, "tmp", "registry")) Popen(["git", "checkout", "stable"]).wait() Popen(['git', 'pull']).wait() src_path = os.path.join(app.root_path, "tmp", "registry", "extensions") for name in os.listdir(src_path): statusfile = open(os.path.join(src_path, name, 'status.yml'), 'r') statusdata = ymlload(statusfile) statusfile.close() if statusdata['approved']: status = statusdata['status'] metafile = open(os.path.join(src_path, name, 'data.yml'), 'r') metadata = ymlload(metafile) metafile.close() datafile = open(os.path.join(src_path, name, 'page.md'), 'r') extdata = datafile.read() datafile.close() row = db.Extension(name=metadata['name']) if not row: slug = Urlify()(metadata['name'])[0] rid = db.Extension.insert( name=metadata['name'], slug=slug ) row = db.Extension(id=rid) row.update_record( status=status, author_name=metadata['author']['name'], author_email=metadata['author']['email'], description=metadata['description'], github=metadata['github'], pypi=metadata['pypi'], version=metadata['version'], website=metadata.get('website'), bugtracker=metadata['bugtracker'], license=metadata['license'], data=extdata ) db.commit()
def build_tree(version): folder = os.path.join(_docs_path, version) if not os.path.exists(folder): return None with open(os.path.join(folder, 'tree.yml')) as f: tree = ymlload(f) complete_tree = [] subpaged = [] for name in tree: if isinstance(name, dict): rname = list(name)[0] subpaged.append(rname) ch_name = get_chapter(version, rname) sub_tree = _get_subpages(version, rname, name[rname]) complete_tree.append((ch_name, rname, sub_tree, [])) else: if name in subpaged: continue ch_name = get_chapter(version, name) sub_tree = get_sections(version, name) complete_tree.append((ch_name, name, [], sub_tree)) return complete_tree
def parse_yaml(data: str) -> Dict[str, Any]: return ymlload(data, Loader=ymlLoader)