/usr/lib/python3/dist-packages/pyaml-17.12.1.egg-info/PKG-INFO is in python3-pretty-yaml 17.12.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 | Metadata-Version: 1.1
Name: pyaml
Version: 17.12.1
Summary: PyYAML-based module to produce pretty and readable YAML-serialized data
Home-page: https://github.com/mk-fg/pretty-yaml
Author: Mike Kazantsev
Author-email: mk.fraggod@gmail.com
License: WTFPL
Description-Content-Type: UNKNOWN
Description: pretty-yaml (or pyaml)
======================
PyYAML-based python module to produce pretty and 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).
.. contents::
:backlinks: none
Warning
-------
Prime goal of this module is to produce human-readable output that can be easily
manipulated and re-used, but maybe with some occasional caveats.
One good example of such "caveat" is that e.g. ``{'foo': '123'}`` will serialize
to ``foo: 123``, which for PyYAML would be a bug, as 123 will then be read back
as an integer from that, but here it's a feature.
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 (e.g. with
options from the next section) for that.
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}, u'some text']
>>> data = dict(a=u'asldnsa\nasldpáknsa\n', b=u'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 tries to improve on that a bit, with the following tweaks:
* Most human-friendly representation options in PyYAML (that I know of) get
picked as defaults.
* Does not dump "null" values, if possible, replacing these with just empty
strings, which have the same meaning but reduce visual clutter and are easier
to edit.
* Dicts, sets, OrderedDicts, defaultdicts, namedtuples, etc are representable
and get sorted on output (OrderedDicts and namedtuples keep their ordering),
so that output would be as diff-friendly as possible, and not arbitrarily
depend on python internals.
It appears that at least recent PyYAML versions also do such sorting for
python dicts.
* List items get indented, as they should be.
* bytestrings that can't be auto-converted to unicode raise error, as yaml has
no "binary bytes" (i.e. unix strings) type.
* 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
...
>>> pyaml.p(cert):
cert: |
-----BEGIN CERTIFICATE-----
MIIH3jCCBcagAwIBAgIJAJi7AjQ4Z87OMA0GCSqGSIb3DQEBCwUAMIHBMRcwFQYD
VQQKFA52YWxlcm9uLm5vX2lzcDEeMBwGA1UECxMVQ2VydGlmaWNhdGUgQXV0aG9y
...
* "force_embed" option to avoid having &id stuff scattered all over the output
(which might be beneficial in some cases, hence the option).
* "&id" anchors, if used, get labels from the keys they get attached to,
not just use meaningless enumerators.
* "string_val_style" option to only apply to strings that are values, not keys,
i.e::
>>> pyaml.p(data, string_val_style='"')
key: "value\nasldpáknsa\n"
>>> yaml.safe_dump(data, sys.stdout, allow_unicode=True, default_style='"')
"key": "value\nasldpáknsa\n"
* Has an option to add vertical spacing (empty lines) between keys on different
depths, to make output much more seekable.
Result for the (rather meaningless) example above (without any additional
tweaks)::
>>> pyaml.p(data)
a: |
asldnsa
asldpáknsa
b: 'whatever text'
ma: &ma
- 123
- 45.67
- 1:
2: false
- 'some text'
mb: *ma
----------
Extended example::
>>> pyaml.dump(conf, sys.stdout, vspacing=[2, 1]):
destination:
encoding:
xz:
enabled: true
min_size: 5120
options:
path_filter:
- \.(gz|bz2|t[gb]z2?|xz|lzma|7z|zip|rar)$
- \.(rpm|deb|iso)$
- \.(jpe?g|gif|png|mov|avi|ogg|mkv|webm|mp[34g]|flv|flac|ape|pdf|djvu)$
- \.(sqlite3?|fossil|fsl)$
- \.git/objects/[0-9a-f]+/[0-9a-f]+$
result:
append_to_file:
append_to_lafs_dir:
print_to_stdout: true
url: http://localhost:3456/uri
filter:
- /(CVS|RCS|SCCS|_darcs|\{arch\})/$
- /\.(git|hg|bzr|svn|cvs)(/|ignore|attributes|tags)?$
- /=(RELEASE-ID|meta-update|update)$
http:
ca_certs_files: /etc/ssl/certs/ca-certificates.crt
debug_requests: false
request_pool_options:
cachedConnectionTimeout: 600
maxPersistentPerHost: 10
retryAutomatically: true
logging:
formatters:
basic:
datefmt: '%Y-%m-%d %H:%M:%S'
format: '%(asctime)s :: %(name)s :: %(levelname)s: %(message)s'
handlers:
console:
class: logging.StreamHandler
formatter: basic
level: custom
stream: ext://sys.stderr
loggers:
twisted:
handlers:
- console
level: 0
root:
handlers:
- console
level: custom
Note that unless there are many moderately wide and deep trees of data, which
are expected to be read and edited by people, it might be preferrable to
directly use PyYAML regardless, as it won't introduce another (rather pointless
in that case) dependency and a point of failure.
Some Tricks
-----------
* Pretty-print any yaml or json (yaml subset) file from the shell::
python -m pyaml /path/to/some/file.yaml
curl -s https://status.github.com/api.json | python -m pyaml
* Easier "debug printf" for more complex data (all funcs below are aliases to
same thing)::
pyaml.p(stuff)
pyaml.pprint(my_data)
pyaml.pprint('----- HOW DOES THAT BREAKS!?!?', input_data, some_var, more_stuff)
pyaml.print(data, file=sys.stderr) # needs "from __future__ import print_function"
* Force all string values to a certain style (see info on these in
`PyYAML docs`_)::
pyaml.dump(many_weird_strings, string_val_style='|')
pyaml.dump(multiline_words, string_val_style='>')
pyaml.dump(no_want_quotes, string_val_style='plain')
Using ``pyaml.add_representer()`` (note \*p\*yaml) as suggested in
`this SO thread`_ (or `github-issue-7`_) should also work.
* Control indent and width of the results::
pyaml.dump(wide_and_deep, indent=4, width=120)
These are actually keywords for PyYAML Emitter (passed to it from Dumper),
see more info on these in `PyYAML docs`_.
.. _PyYAML docs: http://pyyaml.org/wiki/PyYAMLDocumentation#Scalars
.. _this SO thread: http://stackoverflow.com/a/7445560
.. _github-issue-7: https://github.com/mk-fg/pretty-yaml/issues/7
Installation
------------
It's a regular package for Python (3.x or 2.x).
Module uses PyYAML_ for processing of the actual YAML files and should pull it
in as a dependency.
Dependency on unidecode_ module is optional and should only be necessary if
same-id objects or recursion is used within serialized data.
Be sure to use python3/python2, pip3/pip2, easy_install-... binaries below,
based on which python version you want to install the module for, if you have
several on the system (as is norm these days for py2-py3 transition).
Using pip_ is the best way::
% pip install pyaml
(add --user option to install into $HOME for current user only)
Or, if you don't have "pip" command::
% python -m ensurepip
% python -m pip install --upgrade pip
% python -m pip install pyaml
(same suggestion wrt "install --user" as above)
On a very old systems, one of these might work::
% curl https://bootstrap.pypa.io/get-pip.py | python
% pip install pyaml
% easy_install pyaml
% git clone --depth=1 https://github.com/mk-fg/pretty-yaml
% cd pretty-yaml
% python setup.py install
(all of install-commands here also have --user option,
see also `pip docs "installing" section`_)
Current-git version can be installed like this::
% pip install 'git+https://github.com/mk-fg/pretty-yaml#egg=pyaml'
Note that to install stuff to system-wide PATH and site-packages (without
--user), elevated privileges (i.e. root and su/sudo) are often required.
Use "...install --user", `~/.pydistutils.cfg`_ or virtualenv_ to do unprivileged
installs into custom paths.
More info on python packaging can be found at `packaging.python.org`_.
.. _ruamel.yaml: https://bitbucket.org/ruamel/yaml/
.. _PyYAML: http://pyyaml.org/
.. _unidecode: http://pypi.python.org/pypi/Unidecode
.. _pip: http://pip-installer.org/
.. _pip docs "installing" section: http://www.pip-installer.org/en/latest/installing.html
.. _~/.pydistutils.cfg: http://docs.python.org/install/index.html#distutils-configuration-files
.. _virtualenv: http://pypi.python.org/pypi/virtualenv
.. _packaging.python.org: https://packaging.python.org/installing/
Keywords: yaml serialization pretty print format human readable readability
Platform: UNKNOWN
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3.5
Classifier: Topic :: Software Development
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|