Skip to content

Problem wanting to customize YAML writing #10

@john-science

Description

@john-science

So, last week I was working on an armi ticket, and came up with a real need to hide data inside a yamlize.object, that wouldn't be written out to the final YAML. This should have been a small tweak, but ended up being rather hard to trick yamlize to do.

The solutions we came up with were:

  1. Add an Attribute to the yamlize.object and delete it right before we .dump().
  2. Add a hidden class attribute and use Python hasattr to look for it.

So, we had a solution eventually, but we lost a lot of time on it. What would have really helped would be if Yamlize:

  1. Offered a way to make an Attribute "hidden", meaning it would never get written to a YAML.
  2. Offered a way to subclass Attribute, and have that subclass be used throughout the YAML file.

I suppose (1) above would be easier, but (2) would provide a lot more flexibility in the future.

I'd be happy to help implement a solution, if you that's amenable to you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions