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

to_yaml does not indent lists #222

Closed
phackstock opened this issue Jan 16, 2023 · 1 comment
Closed

to_yaml does not indent lists #222

phackstock opened this issue Jan 16, 2023 · 1 comment
Assignees

Comments

@phackstock
Copy link
Contributor

Discovered during 218, reading a yaml file into a CodeList object and dumping it out to yaml again does not work for nested structures.

As an example a variable code list with a region-aggregation attributes:

- Price|Carbon:
    definition: Price of carbon (as reported by the model)
    unit: US$2010/t CO2
    region-aggregation:
        - Price|Carbon (mean):
            method: mean

reading it in and writing it out to yaml again:

VariableCodeList.from_directory("variable", "definitions").to_yaml()

gives the following:

Price|Carbon:
    description: Price of carbon (as reported by the model)
    unit: US$2010/t CO2
    region_aggregation:
    - Price|Carbon (mean):
        method: mean

The indentation under region_aggregation is missing which breaks reading the yaml file.

It seems that this is a known issue with pyyaml (yaml/pyyaml#234 and https://stackoverflow.com/questions/25108581/python-yaml-dump-bad-indentation) so it shouldn't be too hard to fix.

@phackstock
Copy link
Contributor Author

Closed in #218.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant