facilitate modification of serialized YAML that preserves structure and comments
- End-user creates a YAML configuration file by hand, for use with a set of python scripts.
- Python script reads the configuration file, and makes minor changes to be flushed out to the file.
- End-user wishes to continue editing by hand, and expects structure and comments of YAML file to be maintained, not canonicalized.
This was alluded to in an earlier feature request: http://pyyaml.org/ticket/114
I am not familiar with the internal structure of PyYaml, but I would guess that the only possibilities to implement this are:
- to allow the resulting deserialized object to carry along a tokenized version of the original representation
- to allow the serializer to inspect an output file, and navigate it, instead of just blindly writing its output. (This approach doesn't seem like a very clean way to handle it, as it breaks the abstraction of input stream deserialization, output stream serialization.)
If the deserialized object is a "plain" python object made of dicts/lists/strings/numbers, then the original serialization (including comments) is lost.