Skip to content

Commit

Permalink
Use index.yaml to generate directory index in list_priorities. (#234)
Browse files Browse the repository at this point in the history
* Use index.yaml to generate directory index in list_priorities.

As suggested by Steven!, we should parse the index.yaml to
find the list of distributions to parse, rather than having
a hard-coded list.

Signed-off-by: Chris Lalancette <[email protected]>
Co-authored-by: Scott K Logan <[email protected]>
  • Loading branch information
clalancette and cottsay authored Aug 11, 2022
1 parent f6f5f36 commit 7659414
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions list_priorities.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,23 @@
import yamlinclude


DIRECTORIES = ['foxy', 'galactic', 'humble', 'rolling']

def main():
base_path = os.path.dirname(__file__)

# First parse the index.yaml to find the list of distributions that we
# should parse.

yamlinclude.YamlIncludeConstructor.add_to_loader_class(loader_class=yaml.FullLoader, base_dir=base_path)
with open(os.path.join(base_path, 'index.yaml')) as infp:
index_data = yaml.load(infp, Loader=yaml.FullLoader)

directories = list(index_data['distributions'].keys())

del yaml.FullLoader.yaml_constructors[yamlinclude.YamlIncludeConstructor.DEFAULT_TAG_NAME]

priorities = {}

for directory in DIRECTORIES:
for directory in directories:
current_path = os.path.join(base_path, directory)
yamlinclude.YamlIncludeConstructor.add_to_loader_class(loader_class=yaml.FullLoader, base_dir=current_path)

Expand Down

0 comments on commit 7659414

Please sign in to comment.