Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up include file loading code #209

Open
jtwb opened this issue Jan 26, 2023 · 0 comments
Open

Clean up include file loading code #209

jtwb opened this issue Jan 26, 2023 · 0 comments
Labels
cleanup good first issue Good for newcomers

Comments

@jtwb
Copy link
Member

jtwb commented Jan 26, 2023

YAML include files are loaded fully into memory before parsing them with the streaming YAML parser. This is not advantageous in any way except that it makes the many tests in YamlPolicyTermTest fairly compact. It would be better to pass a file stream directly to the YAML loader.

aerleon/aerleon/lib/yaml.py

Lines 333 to 337 in 3085a51

def _LoadIncludeFile(base_dir, inc_filename):
"""Open an include file."""
with open(pathlib.Path(base_dir).joinpath(inc_filename), 'r') as include_file:
return include_file.read()

See also: #208 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cleanup good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant