INNER CODE UNIT · Python

update_markdown

OBOFoundry/OBOFoundry.github.io · util/add_preferred_prefixes.py:21

def update_markdown(path: Union[str, pathlib.Path]) -> None:
    """Update the given markdown file."""
    with open(path) as file:
        lines = [line.rstrip("\n") for line in file]

    assert lines[0] == "---"
    idx = min(i for i, line in enumerate(lines[1:], start=1) if line == "---")

    # Load the data like it is YAML
    data = yaml.safe_load(StringIO("\n".join(lines[1:idx])))

    # For first pass, let's only update ontologies that don't have
    # an explicit entry, and also aren't marked as inactive/obsolete/orphaned
    if "preferredPrefix" in data:
        return
    if "is_obsolete" in data and data["is_obsolete"]:
        return
    if "activity_status" in data and data["activity_status"] in {

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…