def update_db_from_file(filename): """ Parse file for YAML and Markdown and update database. :raises: KeyError or ValueError :param filename: path to markdown file. :return: SecurityAdvisory instance """ if HOF_DIRECTORY in filename: return add_hofers(filename, parse_yml_file_base(filename)) if filename.endswith('.md'): parser = parse_md_file elif filename.endswith('.yml'): parser = parse_yml_file else: raise RuntimeError('Unknown file type %s' % filename) return add_or_update_advisory(*parser(filename))
def update_db_from_file(filename): """ Parse file for YAML and Markdown and update database. :raises: KeyError or ValueError :param filename: path to markdown file. :return: SecurityAdvisory instance """ if HOF_DIRECTORY in filename: return add_hofers(filename, parse_yml_file_base(filename)) if filename.endswith('.md'): parser = parse_md_file elif filename.endswith('.yml'): parser = parse_yml_file else: raise RuntimeError('Unknown file type %s' % filename) data, html = parser(filename) if 'advisories' in data: add_or_update_cve(data) return add_or_update_advisory(data, html)
def update_db_from_file(filename): """ Parse file for YAML and Markdown and update database. :raises: KeyError or ValueError :param filename: path to markdown file. :return: SecurityAdvisory instance """ if HOF_DIRECTORY in filename: return add_hofers(filename, parse_yml_file_base(filename)) if filename.endswith(".md"): parser = parse_md_file elif filename.endswith(".yml"): parser = parse_yml_file else: raise RuntimeError(f"Unknown file type {filename}") data, html = parser(filename) if "advisories" in data: add_or_update_cve(data) return add_or_update_advisory(data, html)