mk-fg / pretty-yaml

PyYAML-based module to produce a bit more pretty and readable YAML-serialized data
Do What The F*ck You Want To Public License
135 stars 29 forks source link

Format and write into file #31

Closed mirzawaqasahmed closed 4 years ago

mirzawaqasahmed commented 4 years ago

Hi, Great project.... Just wanted to check if there is a way to input a file, prettify it and then write back to the same file?

Thanks

mk-fg commented 4 years ago

There wasn't but quite easy to add, so added -r/--replace command-line option in 9ecfb29.

Update the module, and you should be able to do it via something like:

% python -m pyaml -r file-with-json.data

It does that via temporary file, but without fsync/fdatasync, which I think should be reasonably safe and not too demanding for such simple use-case.

Hope it helps, cheers!

mirzawaqasahmed commented 4 years ago

Thanks will try and get back if something else comes up..