python-pyaml
Port variant py310
Summary Produce readable YAML-serialized data (3.10)
Package version 23.9.6
Homepage https://github.com/mk-fg/pretty-yaml
Keywords python
Maintainer Python Automaton
License Not yet specified
Other variants v11
Ravenports Buildsheet | History
Ravensource Port Directory | History
Last modified 22 SEP 2023, 12:17:47 UTC
Port created 07 JAN 2023, 04:18:24 UTC
Subpackage Descriptions
single pretty-yaml (or pyaml) ====================== PyYAML_-based python module to produce a bit more pretty and human-readable YAML-serialized data. This module is for serialization only, see `ruamel.yaml`_ module for literate YAML parsing (keeping track of comments, spacing, line/column numbers of values, etc). (side-note: to dump stuff parsed by ruamel.yaml with this module, use only ``YAML(typ='safe')`` there) It's a small module, and for projects that only need part of its functionality, I'd recommend copy-pasting that in, instead of adding janky dependency. .. _PyYAML: http://pyyaml.org/ .. _ruamel.yaml: https://bitbucket.org/ruamel/yaml/ .. contents:: :backlinks: none Repository URLs: - https://github.com/mk-fg/pretty-yaml - https://codeberg.org/mk-fg/pretty-yaml - https://fraggod.net/code/git/pretty-yaml Warning ------- Prime goal of this module is to produce human-readable output that can be easily diff'ed, manipulated and re-used, but maybe with occasional issues. So please do not rely on the thing to produce output that can always be deserialized exactly to what was exported, at least - use PyYAML directly for that (but maybe with options from the next section). What this module does and why ----------------------------- YAML is generally nice and easy format to read *if* it was written by humans. PyYAML can a do fairly decent job of making stuff readable, and the best combination of parameters for such output that I've seen so far is probably this one:: >>> m = [123, 45.67, {1: None, 2: False}, 'some text'] >>> data = dict(a='asldnsa\nasldpáknsa\n', b='whatever text', ma=m, mb=m) >>> yaml.safe_dump(data, sys.stdout, allow_unicode=True, default_flow_style=False) a: 'asldnsa asldpáknsa ' b: whatever text ma: &id001 - 123 - 45.67 - 1: null 2: false - some text mb: *id001 pyaml (this module) tries to improve on that a bit, with the following tweaks: * Most human-friendly representation options in PyYAML (that I know of) are used as defaults. * Dump "null" values as empty values, if possible, which have the same meaning but reduce visual clutter and are easier to edit. * Dicts, sets, OrderedDicts, defaultdicts, namedtuples, enums, dataclasses, etc are represented as their safe YAML-compatible base (like int, list or mapping), with mappings key-sorted by default for more diff-friendly output. * Use shorter and simplier yes/no for booleans. * List items get indented, as they should be. * Attempt is made to pick more readable string representation styles, depending on the value, e.g.:: >>> yaml.safe_dump(cert, sys.stdout) cert: '-----BEGIN CERTIFICATE----- MIIH3jCCBcagAwIBAgIJAJi7AjQ4Z87OMA0GCSqGSIb3DQEBCwUAMIHBMRcwFQYD VQQKFA52YWxlcm9uLm5vX2lzcDEeMBwGA1UECxMVQ2VydGlmaWNhdGUgQXV0aG9y ...
Configuration Switches (platform-specific settings discarded)
PY310 ON Build using Python 3.10 PY311 OFF Build using Python 3.11
Package Dependencies by Type
Build (only) python-pip:single:py310
autoselect-python:single:standard
Build and Runtime python310:single:standard
Runtime (only) python-PyYAML:single:py310
Download groups
main mirror://PYPIWHL/56/db/01bc52d991716ccac7366b6e763fdaaf7b57910dbc2f85466c997f915284
Distribution File Information
9dcc67922b7278f3680e573324b2e8a8d2f86c5d09bf640cba83735fb1663e97 22965 pyaml-23.9.6-py3-none-any.whl
Ports that require python-pyaml:py310
python-nb2an:py310 Netbox to Ansible config comparison tool (3.10)