Hello community, here is the log from the commit of package python-pyaml for openSUSE:Factory checked in at 2019-05-16 22:08:52 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-pyaml (Old) and /work/SRC/openSUSE:Factory/.python-pyaml.new.5148 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-pyaml" Thu May 16 22:08:52 2019 rev:4 rq:703228 version:19.4.1 Changes: -------- --- /work/SRC/openSUSE:Factory/python-pyaml/python-pyaml.changes 2018-09-20 11:41:41.088848594 +0200 +++ /work/SRC/openSUSE:Factory/.python-pyaml.new.5148/python-pyaml.changes 2019-05-16 22:08:55.254343656 +0200 @@ -1,0 +2,6 @@ +Wed May 15 17:37:38 UTC 2019 - Gary Smith <[email protected]> + +- Update to version 19.4.1 + * no changelog available + +------------------------------------------------------------------- Old: ---- pyaml-17.12.1.tar.gz New: ---- pyaml-19.4.1.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-pyaml.spec ++++++ --- /var/tmp/diff_new_pack.miNsm7/_old 2019-05-16 22:08:56.770342279 +0200 +++ /var/tmp/diff_new_pack.miNsm7/_new 2019-05-16 22:08:56.802342250 +0200 @@ -1,7 +1,7 @@ # # spec file for package python-pyaml # -# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -12,13 +12,13 @@ # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. -# Please submit bugfixes or comments via http://bugs.opensuse.org/ +# Please submit bugfixes or comments via https://bugs.opensuse.org/ # %{?!python_module:%define python_module() python-%{**} python3-%{**}} Name: python-pyaml -Version: 17.12.1 +Version: 19.4.1 Release: 0 Summary: Python module to produce formatted YAML-serialized data License: WTFPL ++++++ pyaml-17.12.1.tar.gz -> pyaml-19.4.1.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyaml-17.12.1/PKG-INFO new/pyaml-19.4.1/PKG-INFO --- old/pyaml-17.12.1/PKG-INFO 2017-12-23 21:27:16.000000000 +0100 +++ new/pyaml-19.4.1/PKG-INFO 2019-04-17 04:29:06.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: pyaml -Version: 17.12.1 +Version: 19.4.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 @@ -112,6 +112,10 @@ >>> yaml.safe_dump(data, sys.stdout, allow_unicode=True, default_style='"') "key": "value\nasldpáknsa\n" + * "sort_dicts=False" option to leave dict item ordering to python, and not + force-sort them in yaml output, which can be important for python 3.6+ where + they retain ordering info. + * Has an option to add vertical spacing (empty lines) between keys on different depths, to make output much more seekable. @@ -240,6 +244,10 @@ These are actually keywords for PyYAML Emitter (passed to it from Dumper), see more info on these in `PyYAML docs`_. + * Dump multiple yaml documents into a file: ``pyaml.dump_all([data1, data2, data3], dst_file)`` + + explicit_start=True is implied, unless explicit_start=False is passed. + .. _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 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyaml-17.12.1/README new/pyaml-19.4.1/README --- old/pyaml-17.12.1/README 2019-05-16 22:08:57.234341858 +0200 +++ new/pyaml-19.4.1/README 2019-04-17 04:03:22.000000000 +0200 @@ -1 +1,310 @@ -symbolic link to README.rst +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" + +* "sort_dicts=False" option to leave dict item ordering to python, and not + force-sort them in yaml output, which can be important for python 3.6+ where + they retain ordering info. + +* 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`_. + +* Dump multiple yaml documents into a file: ``pyaml.dump_all([data1, data2, data3], dst_file)`` + + explicit_start=True is implied, unless explicit_start=False is passed. + +.. _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/ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyaml-17.12.1/README.rst new/pyaml-19.4.1/README.rst --- old/pyaml-17.12.1/README.rst 2017-10-08 03:32:09.000000000 +0200 +++ new/pyaml-19.4.1/README.rst 2019-04-17 04:03:22.000000000 +0200 @@ -104,6 +104,10 @@ >>> yaml.safe_dump(data, sys.stdout, allow_unicode=True, default_style='"') "key": "value\nasldpáknsa\n" +* "sort_dicts=False" option to leave dict item ordering to python, and not + force-sort them in yaml output, which can be important for python 3.6+ where + they retain ordering info. + * Has an option to add vertical spacing (empty lines) between keys on different depths, to make output much more seekable. @@ -232,6 +236,10 @@ These are actually keywords for PyYAML Emitter (passed to it from Dumper), see more info on these in `PyYAML docs`_. +* Dump multiple yaml documents into a file: ``pyaml.dump_all([data1, data2, data3], dst_file)`` + + explicit_start=True is implied, unless explicit_start=False is passed. + .. _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 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyaml-17.12.1/pyaml/__init__.py new/pyaml-19.4.1/pyaml/__init__.py --- old/pyaml-17.12.1/pyaml/__init__.py 2017-12-23 21:26:39.000000000 +0100 +++ new/pyaml-19.4.1/pyaml/__init__.py 2019-04-17 04:24:52.000000000 +0200 @@ -3,7 +3,7 @@ import itertools as it, operator as op, functools as ft from collections import defaultdict, OrderedDict, namedtuple -import os, sys, io +import os, sys, io, re import yaml @@ -15,6 +15,7 @@ def __init__(self, *args, **kws): self.pyaml_force_embed = kws.pop('force_embed', False) self.pyaml_string_val_style = kws.pop('string_val_style', None) + self.pyaml_sort_dicts = kws.pop('sort_dicts', True) return super(PrettyYAMLDumper, self).__init__(*args, **kws) def represent_odict(dumper, data): @@ -38,6 +39,10 @@ elif callable(getattr(data, 'tolist', None)): return dumper.represent_data(data.tolist()) return super(PrettyYAMLDumper, dumper).represent_undefined(data) + def represent_dict(dumper, data): + if not dumper.pyaml_sort_dicts: return dumper.represent_odict(data) + return super(PrettyYAMLDumper, dumper).represent_dict(data) + def serialize_node(self, node, parent, index): if self.pyaml_force_embed: self.serialized_nodes.clear() return super(PrettyYAMLDumper, self).serialize_node(node, parent, index) @@ -70,6 +75,7 @@ self.anchor_node(key) self.anchor_node(value, hint=hint+[key]) +PrettyYAMLDumper.add_representer(dict, PrettyYAMLDumper.represent_dict) PrettyYAMLDumper.add_representer(defaultdict, PrettyYAMLDumper.represent_dict) PrettyYAMLDumper.add_representer(OrderedDict, PrettyYAMLDumper.represent_odict) PrettyYAMLDumper.add_representer(set, PrettyYAMLDumper.represent_list) @@ -157,7 +163,7 @@ level = 0 line = line.decode('utf-8') result.append(line) - if ':' in line: + if ':' in line or re.search(r'---(\s*$|\s)', line): while line.startswith(' '): level, line = level + 1, line[2:] if len(vspacing) > level and len(result) != 1: @@ -168,12 +174,18 @@ buff.write(''.join(result).encode('utf-8')) -def dump( data, dst=unicode, safe=False, - force_embed=False, vspacing=None, string_val_style=None, **pyyaml_kws ): +def dump_all(data, *dump_args, **dump_kws): + return dump(data, *dump_args, multiple_docs=True, **dump_kws) + +def dump( data, dst=unicode, safe=False, force_embed=False, vspacing=None, + string_val_style=None, sort_dicts=True, multiple_docs=False, **pyyaml_kws ): buff = io.BytesIO() Dumper = PrettyYAMLDumper if safe else UnsafePrettyYAMLDumper - Dumper = ft.partial(Dumper, force_embed=force_embed, string_val_style=string_val_style) - yaml.dump_all( [data], buff, Dumper=Dumper, + Dumper = ft.partial( Dumper, + force_embed=force_embed, string_val_style=string_val_style, sort_dicts=sort_dicts ) + if not multiple_docs: data = [data] + else: pyyaml_kws.setdefault('explicit_start', True) + yaml.dump_all( data, buff, Dumper=Dumper, default_flow_style=False, allow_unicode=True, encoding='utf-8', **pyyaml_kws ) if vspacing is not None: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyaml-17.12.1/pyaml/tests/dump.py new/pyaml-19.4.1/pyaml/tests/dump.py --- old/pyaml-17.12.1/pyaml/tests/dump.py 2016-12-08 21:16:00.000000000 +0100 +++ new/pyaml-19.4.1/pyaml/tests/dump.py 2019-04-17 04:28:22.000000000 +0200 @@ -403,6 +403,21 @@ self.assertLess(len(line), w*1.2) if n != len(lines): self.assertGreater(len(line), w*0.8) + def test_multiple_docs(self): + docs = [yaml.safe_load(large_yaml), dict(a=1, b=2, c=3)] + docs_str = pyaml.dump_all(docs, vspacing=[3, 2]) + self.assertTrue(docs_str.startswith('---')) + self.assertIn('---\n\n\n\na: 1\n\n\n\nb: 2\n\n\n\nc: 3\n', docs_str) + docs_str2 = pyaml.dump(docs, vspacing=[3, 2], multiple_docs=True) + self.assertEqual(docs_str, docs_str2) + docs_str2 = pyaml.dump(docs, vspacing=[3, 2]) + self.assertNotEqual(docs_str, docs_str2) + docs_str2 = pyaml.dump_all(docs, explicit_start=False) + self.assertFalse(docs_str2.startswith('---')) + self.assertNotEqual(docs_str, docs_str2) + docs_str = pyaml.dump(docs, multiple_docs=True, explicit_start=False) + self.assertEqual(docs_str, docs_str2) + if __name__ == '__main__': unittest.main() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyaml-17.12.1/pyaml.egg-info/PKG-INFO new/pyaml-19.4.1/pyaml.egg-info/PKG-INFO --- old/pyaml-17.12.1/pyaml.egg-info/PKG-INFO 2017-12-23 21:27:16.000000000 +0100 +++ new/pyaml-19.4.1/pyaml.egg-info/PKG-INFO 2019-04-17 04:29:06.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: pyaml -Version: 17.12.1 +Version: 19.4.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 @@ -112,6 +112,10 @@ >>> yaml.safe_dump(data, sys.stdout, allow_unicode=True, default_style='"') "key": "value\nasldpáknsa\n" + * "sort_dicts=False" option to leave dict item ordering to python, and not + force-sort them in yaml output, which can be important for python 3.6+ where + they retain ordering info. + * Has an option to add vertical spacing (empty lines) between keys on different depths, to make output much more seekable. @@ -240,6 +244,10 @@ These are actually keywords for PyYAML Emitter (passed to it from Dumper), see more info on these in `PyYAML docs`_. + * Dump multiple yaml documents into a file: ``pyaml.dump_all([data1, data2, data3], dst_file)`` + + explicit_start=True is implied, unless explicit_start=False is passed. + .. _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 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyaml-17.12.1/setup.cfg new/pyaml-19.4.1/setup.cfg --- old/pyaml-17.12.1/setup.cfg 2017-12-23 21:27:16.000000000 +0100 +++ new/pyaml-19.4.1/setup.cfg 2019-04-17 04:29:06.000000000 +0200 @@ -4,5 +4,4 @@ [egg_info] tag_build = tag_date = 0 -tag_svn_revision = 0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyaml-17.12.1/setup.py new/pyaml-19.4.1/setup.py --- old/pyaml-17.12.1/setup.py 2017-12-23 21:22:03.000000000 +0100 +++ new/pyaml-19.4.1/setup.py 2019-04-17 04:28:35.000000000 +0200 @@ -12,7 +12,7 @@ setup( name = 'pyaml', - version = '17.12.1', + version = '19.4.1', author = 'Mike Kazantsev', author_email = '[email protected]', license = 'WTFPL',
