Skip to content
This repository has been archived by the owner on Feb 2, 2023. It is now read-only.

Commit

Permalink
Merge cc6c4e2 into d21ed8d
Browse files Browse the repository at this point in the history
  • Loading branch information
mcdonnnj committed Jan 24, 2022
2 parents d21ed8d + cc6c4e2 commit 6d4e755
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/mdyml/convert_cisagov.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@
EXPECTED_COLUMN_COUNT = len(EXPECTED_COLUMN_NAMES)


class NoAliasesRoundTripRepresenter(ruamel.yaml.representer.RoundTripRepresenter):
"""Helper class to eliminate YAML anchors in YAML output."""

def ignore_aliases(self, data):
"""Override the default method to always ignore aliases."""
return True


def convert() -> None:
"""Parse the Markdown at the given URL and convert it to YAML."""
# Get the Markdown
Expand Down Expand Up @@ -202,6 +210,7 @@ def convert() -> None:
}

yaml = ruamel.yaml.YAML()
yaml.Representer = NoAliasesRoundTripRepresenter
yaml.indent(mapping=2, offset=2, sequence=4)
yaml.explicit_start = True
yaml.explicit_end = True
Expand Down
9 changes: 9 additions & 0 deletions src/yml/normalize_yml.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@
YamlData = dict[str, Software | Owners]


class NoAliasesRoundTripRepresenter(ruamel.yaml.representer.RoundTripRepresenter):
"""Helper class to eliminate YAML anchors in YAML output."""

def ignore_aliases(self, data):
"""Override the default method to always ignore aliases."""
return True


def munge(filenames: list[str], canonical=False) -> YamlData:
"""Munge together the "owners" and "software" nodes from YAML files into a single Python dictionary."""
ans = []
Expand Down Expand Up @@ -116,6 +124,7 @@ def main() -> None:
doc = data["software"]

yml = ruamel.yaml.YAML()
yml.Representer = NoAliasesRoundTripRepresenter
yml.indent(mapping=2, offset=2, sequence=4)
yml.explicit_start = True
yml.explicit_end = True
Expand Down

0 comments on commit 6d4e755

Please sign in to comment.