single |
ruamel.yaml supports YAML 1.2 and has round-trip loaders and dumpers.
A round-trip is a YAML load-modify-save sequence and ruamel.yaml tries to
preserve, among others:
* comments
* block style and key ordering are kept, so you can diff the
round-tripped source
* flow style sequences ( 'a: b, c, d') (based on request and test by
Anthony Sottile)
* anchor names that are hand-crafted (i.e. not of the formidNNN)
* merges in dictionaries are preserved
* This preservation is normally not broken unless you severely alter
the structure of a component (delete a key in a dict, remove list
entries). Reassigning values or replacing list items, etc., is fine.
Although individual indentation of lines is not preserved, you can specify
separate indentation levels for mappings and sequences (counting for
sequences does not include the dash for a sequence element) and specific
offset of block sequence dashes within that indentation.
|