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

yaml roundtripping comments and whitespace #140

Open
yaythomas opened this issue Apr 5, 2019 · 0 comments
Open

yaml roundtripping comments and whitespace #140

yaythomas opened this issue Apr 5, 2019 · 0 comments
Labels
enhancement new features type: step steps

Comments

@yaythomas
Copy link
Member

yaythomas commented Apr 5, 2019

the yaml roundtripping filewrite/fileformat steps do not preserve comments in the source yaml on the outfile.
the ruamel in/out is correct, but the context.get_formatted_iterable doesn't deal with the special cases necessary to bring across the comment info also. . .

it'll likely need something like this:

if isinstance(n, ruamel.yaml.comments.CommentedMap):
        for k in n:
            d[k] = update(d[k], n[k]) if k in d else n[k]
            if k in n.ca._items and n.ca._items[k][2] and \
               n.ca._items[k][2].value.strip():
                d.ca._items[k] = n.ca._items[k]  # copy non-empty comment
    else:
        d = n
    return d```

with similar for Lists.
@yaythomas yaythomas added enhancement new features type: step steps labels Apr 5, 2019
@yaythomas yaythomas added this to To do in pypyr roadmap via automation Apr 5, 2019
@yaythomas yaythomas changed the title yaml roundtripping yaml roundtripping comments and whitespace Apr 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement new features type: step steps
Projects
pypyr roadmap
  
To do
Development

No branches or pull requests

1 participant