commit python-jsonpatch for openSUSE:Factory
Hello community, here is the log from the commit of package python-jsonpatch for openSUSE:Factory checked in at 2016-12-08 00:29:53 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-jsonpatch (Old) and /work/SRC/openSUSE:Factory/.python-jsonpatch.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "python-jsonpatch" Changes: -------- --- /work/SRC/openSUSE:Factory/python-jsonpatch/python-jsonpatch.changes 2016-08-17 12:05:45.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.python-jsonpatch.new/python-jsonpatch.changes 2016-12-08 00:29:54.000000000 +0100 @@ -1,0 +2,5 @@ +Tue Nov 15 10:53:42 UTC 2016 - dmueller@suse.com + +- udpate to 1.14.0 + +------------------------------------------------------------------- Old: ---- jsonpatch-1.11.tar.gz New: ---- jsonpatch-1.14.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-jsonpatch.spec ++++++ --- /var/tmp/diff_new_pack.w2wWiU/_old 2016-12-08 00:29:55.000000000 +0100 +++ /var/tmp/diff_new_pack.w2wWiU/_new 2016-12-08 00:29:55.000000000 +0100 @@ -1,7 +1,7 @@ # # spec file for package python-jsonpatch # -# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2016 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 @@ -17,13 +17,13 @@ Name: python-jsonpatch -Version: 1.11 +Version: 1.14 Release: 0 Summary: Python - JSON-Patches License: BSD-3-Clause Group: Development/Languages/Python Url: https://github.com/stefankoegl/python-json-patch -Source: http://pypi.python.org/packages/source/j/jsonpatch/jsonpatch-%{version}.tar.gz +Source: https://pypi.io/packages/source/j/jsonpatch/jsonpatch-%{version}.tar.gz BuildRequires: python-devel BuildRequires: python-jsonpointer Requires: python-jsonpointer >= 1.9 ++++++ jsonpatch-1.11.tar.gz -> jsonpatch-1.14.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonpatch-1.11/PKG-INFO new/jsonpatch-1.14/PKG-INFO --- old/jsonpatch-1.11/PKG-INFO 2015-05-08 18:10:53.000000000 +0200 +++ new/jsonpatch-1.14/PKG-INFO 2016-05-31 20:24:55.000000000 +0200 @@ -1,34 +1,46 @@ Metadata-Version: 1.1 Name: jsonpatch -Version: 1.11 +Version: 1.14 Summary: Apply JSON-Patches (RFC 6902) Home-page: https://github.com/stefankoegl/python-json-patch Author: Stefan Kögl Author-email: stefan@skoegl.net License: Modified BSD License -Description: python-json-patch [![Build Status](https://secure.travis-ci.org/stefankoegl/python-json-patch.png?branch=master)](https://travis-ci.org/stefankoegl/python-json-patch) [![Coverage Status](https://coveralls.io/repos/stefankoegl/python-json-patch/badge.png?branch=master)](https://coveralls.io/r/stefankoegl/python-json-patch?branch=master) ![Downloads](https://pypip.in/d/jsonpatch/badge.png) ![Version](https://pypip.in/v/jsonpatch/badge.png) - ================= +Description: python-json-patch |Build Status| |Coverage Status| |Downloads| |Version| + ======================================================================== + Applying JSON Patches in Python ------------------------------- - Library to apply JSON Patches according to - [RFC 6902](http://tools.ietf.org/html/rfc6902) + Library to apply JSON Patches according to `RFC + 6902 <http://tools.ietf.org/html/rfc6902>`__ See Sourcecode for Examples - * Website: https://github.com/stefankoegl/python-json-patch - * Repository: https://github.com/stefankoegl/python-json-patch.git - * Documentation: https://python-json-patch.readthedocs.org/ - * PyPI: https://pypi.python.org/pypi/jsonpatch - * Travis-CI: https://travis-ci.org/stefankoegl/python-json-patch - * Coveralls: https://coveralls.io/r/stefankoegl/python-json-patch + - Website: https://github.com/stefankoegl/python-json-patch + - Repository: https://github.com/stefankoegl/python-json-patch.git + - Documentation: https://python-json-patch.readthedocs.org/ + - PyPI: https://pypi.python.org/pypi/jsonpatch + - Travis-CI: https://travis-ci.org/stefankoegl/python-json-patch + - Coveralls: https://coveralls.io/r/stefankoegl/python-json-patch Running external tests ---------------------- - To run external tests (such as those from https://github.com/json-patch/json-patch-tests) use ext_test.py + + To run external tests (such as those from + https://github.com/json-patch/json-patch-tests) use ext\_test.py + + :: ./ext_tests.py ../json-patch-tests/tests.json + .. |Build Status| image:: https://secure.travis-ci.org/stefankoegl/python-json-patch.png?branch=master + :target: https://travis-ci.org/stefankoegl/python-json-patch + .. |Coverage Status| image:: https://coveralls.io/repos/stefankoegl/python-json-patch/badge.png?branch=ma... + :target: https://coveralls.io/r/stefankoegl/python-json-patch?branch=master + .. |Downloads| image:: https://pypip.in/d/jsonpatch/badge.png + .. |Version| image:: https://pypip.in/v/jsonpatch/badge.png + Platform: UNKNOWN Classifier: Development Status :: 5 - Production/Stable Classifier: Environment :: Console @@ -43,6 +55,7 @@ Classifier: Programming Language :: Python :: 3.2 Classifier: Programming Language :: Python :: 3.3 Classifier: Programming Language :: Python :: 3.4 +Classifier: Programming Language :: Python :: 3.5 Classifier: Programming Language :: Python :: Implementation :: CPython Classifier: Programming Language :: Python :: Implementation :: PyPy Classifier: Topic :: Software Development :: Libraries diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonpatch-1.11/ext_tests.py new/jsonpatch-1.14/ext_tests.py --- old/jsonpatch-1.11/ext_tests.py 2013-12-25 12:54:46.000000000 +0100 +++ new/jsonpatch-1.14/ext_tests.py 2016-02-13 15:35:46.000000000 +0100 @@ -60,12 +60,15 @@ ) else: - res = jsonpatch.apply_patch(test['doc'], test['patch']) + try: + res = jsonpatch.apply_patch(test['doc'], test['patch']) + except jsonpatch.JsonPatchException as jpe: + raise Exception(test.get('comment', '')) from jpe # if there is no 'expected' we only verify that applying the patch # does not raies an exception if 'expected' in test: - self.assertEquals(res, test['expected']) + self.assertEquals(res, test['expected'], test.get('comment', '')) def make_test_case(tests): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonpatch-1.11/jsonpatch.egg-info/PKG-INFO new/jsonpatch-1.14/jsonpatch.egg-info/PKG-INFO --- old/jsonpatch-1.11/jsonpatch.egg-info/PKG-INFO 2015-05-08 18:10:53.000000000 +0200 +++ new/jsonpatch-1.14/jsonpatch.egg-info/PKG-INFO 2016-05-31 20:24:55.000000000 +0200 @@ -1,34 +1,46 @@ Metadata-Version: 1.1 Name: jsonpatch -Version: 1.11 +Version: 1.14 Summary: Apply JSON-Patches (RFC 6902) Home-page: https://github.com/stefankoegl/python-json-patch Author: Stefan Kögl Author-email: stefan@skoegl.net License: Modified BSD License -Description: python-json-patch [![Build Status](https://secure.travis-ci.org/stefankoegl/python-json-patch.png?branch=master)](https://travis-ci.org/stefankoegl/python-json-patch) [![Coverage Status](https://coveralls.io/repos/stefankoegl/python-json-patch/badge.png?branch=master)](https://coveralls.io/r/stefankoegl/python-json-patch?branch=master) ![Downloads](https://pypip.in/d/jsonpatch/badge.png) ![Version](https://pypip.in/v/jsonpatch/badge.png) - ================= +Description: python-json-patch |Build Status| |Coverage Status| |Downloads| |Version| + ======================================================================== + Applying JSON Patches in Python ------------------------------- - Library to apply JSON Patches according to - [RFC 6902](http://tools.ietf.org/html/rfc6902) + Library to apply JSON Patches according to `RFC + 6902 <http://tools.ietf.org/html/rfc6902>`__ See Sourcecode for Examples - * Website: https://github.com/stefankoegl/python-json-patch - * Repository: https://github.com/stefankoegl/python-json-patch.git - * Documentation: https://python-json-patch.readthedocs.org/ - * PyPI: https://pypi.python.org/pypi/jsonpatch - * Travis-CI: https://travis-ci.org/stefankoegl/python-json-patch - * Coveralls: https://coveralls.io/r/stefankoegl/python-json-patch + - Website: https://github.com/stefankoegl/python-json-patch + - Repository: https://github.com/stefankoegl/python-json-patch.git + - Documentation: https://python-json-patch.readthedocs.org/ + - PyPI: https://pypi.python.org/pypi/jsonpatch + - Travis-CI: https://travis-ci.org/stefankoegl/python-json-patch + - Coveralls: https://coveralls.io/r/stefankoegl/python-json-patch Running external tests ---------------------- - To run external tests (such as those from https://github.com/json-patch/json-patch-tests) use ext_test.py + + To run external tests (such as those from + https://github.com/json-patch/json-patch-tests) use ext\_test.py + + :: ./ext_tests.py ../json-patch-tests/tests.json + .. |Build Status| image:: https://secure.travis-ci.org/stefankoegl/python-json-patch.png?branch=master + :target: https://travis-ci.org/stefankoegl/python-json-patch + .. |Coverage Status| image:: https://coveralls.io/repos/stefankoegl/python-json-patch/badge.png?branch=ma... + :target: https://coveralls.io/r/stefankoegl/python-json-patch?branch=master + .. |Downloads| image:: https://pypip.in/d/jsonpatch/badge.png + .. |Version| image:: https://pypip.in/v/jsonpatch/badge.png + Platform: UNKNOWN Classifier: Development Status :: 5 - Production/Stable Classifier: Environment :: Console @@ -43,6 +55,7 @@ Classifier: Programming Language :: Python :: 3.2 Classifier: Programming Language :: Python :: 3.3 Classifier: Programming Language :: Python :: 3.4 +Classifier: Programming Language :: Python :: 3.5 Classifier: Programming Language :: Python :: Implementation :: CPython Classifier: Programming Language :: Python :: Implementation :: PyPy Classifier: Topic :: Software Development :: Libraries diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonpatch-1.11/jsonpatch.egg-info/SOURCES.txt new/jsonpatch-1.14/jsonpatch.egg-info/SOURCES.txt --- old/jsonpatch-1.11/jsonpatch.egg-info/SOURCES.txt 2015-05-08 18:10:53.000000000 +0200 +++ new/jsonpatch-1.14/jsonpatch.egg-info/SOURCES.txt 2016-05-31 20:24:55.000000000 +0200 @@ -5,6 +5,7 @@ ext_tests.py jsonpatch.py requirements.txt +setup.cfg setup.py tests.py bin/jsondiff diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonpatch-1.11/jsonpatch.egg-info/requires.txt new/jsonpatch-1.14/jsonpatch.egg-info/requires.txt --- old/jsonpatch-1.11/jsonpatch.egg-info/requires.txt 2015-05-08 18:10:53.000000000 +0200 +++ new/jsonpatch-1.14/jsonpatch.egg-info/requires.txt 2016-05-31 20:24:55.000000000 +0200 @@ -1 +1 @@ -jsonpointer>=1.9 +jsonpointer>=1.9 \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonpatch-1.11/jsonpatch.py new/jsonpatch-1.14/jsonpatch.py --- old/jsonpatch-1.11/jsonpatch.py 2015-05-08 18:07:25.000000000 +0200 +++ new/jsonpatch-1.14/jsonpatch.py 2016-05-31 18:51:21.000000000 +0200 @@ -51,7 +51,7 @@ # Will be parsed by setup.py to determine package metadata __author__ = 'Stefan Kögl <stefan@skoegl.net>' -__version__ = '1.11' +__version__ = '1.14' __website__ = 'https://github.com/stefankoegl/python-json-patch' __license__ = 'Modified BSD License' @@ -484,6 +484,10 @@ except (KeyError, IndexError) as ex: raise JsonPatchConflict(str(ex)) + # If source and target are equal, this is a no-op + if self.pointer == from_ptr: + return obj + if isinstance(subobj, MutableMapping) and \ self.pointer.contains(from_ptr): raise JsonPatchConflict('Cannot move values into its own children') @@ -641,7 +645,7 @@ (by[0], by[0] + y[0])), _split_by_common_seq(src[x[1]:], dst[y[1]:], (bx[0] + x[1], bx[0] + len(src)), - (bx[0] + y[1], bx[0] + len(dst)))] + (by[0] + y[1], by[0] + len(dst)))] def _compare(path, src, dst, left, right): @@ -756,11 +760,18 @@ def _optimize_using_replace(prev, cur): - """Optimises JSON patch by using ``replace`` operation instead of - ``remove`` and ``add`` against the same path.""" + """Optimises by replacing ``add``/``remove`` with ``replace`` on same path + + For nested strucures, tries to recurse replacement, see #36 """ prev['op'] = 'replace' if cur['op'] == 'add': - prev['value'] = cur['value'] + # make recursive patch + patch = make_patch(prev['value'], cur['value']) + if len(patch.patch) == 1 and patch.patch[0]['op'] != 'remove': + prev['path'] = prev['path'] + patch.patch[0]['path'] + prev['value'] = patch.patch[0]['value'] + else: + prev['value'] = cur['value'] def _optimize_using_move(prev_item, item): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonpatch-1.11/setup.cfg new/jsonpatch-1.14/setup.cfg --- old/jsonpatch-1.11/setup.cfg 2015-05-08 18:10:53.000000000 +0200 +++ new/jsonpatch-1.14/setup.cfg 2016-05-31 20:24:55.000000000 +0200 @@ -1,5 +1,8 @@ +[bdist_wheel] +universal = 1 + [egg_info] -tag_build = -tag_date = 0 tag_svn_revision = 0 +tag_date = 0 +tag_build = diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonpatch-1.11/setup.py new/jsonpatch-1.14/setup.py --- old/jsonpatch-1.11/setup.py 2014-10-25 15:26:26.000000000 +0200 +++ new/jsonpatch-1.14/setup.py 2016-02-13 19:04:52.000000000 +0100 @@ -1,4 +1,5 @@ #!/usr/bin/env python +# -*- coding: utf-8 -*- import sys import io @@ -66,6 +67,7 @@ 'Programming Language :: Python :: 3.2', 'Programming Language :: Python :: 3.3', 'Programming Language :: Python :: 3.4', + 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: Implementation :: CPython', 'Programming Language :: Python :: Implementation :: PyPy', 'Topic :: Software Development :: Libraries', diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonpatch-1.11/tests.py new/jsonpatch-1.14/tests.py --- old/jsonpatch-1.11/tests.py 2015-05-08 18:03:57.000000000 +0200 +++ new/jsonpatch-1.14/tests.py 2016-05-31 18:46:45.000000000 +0200 @@ -317,6 +317,15 @@ res = jsonpatch.apply_patch(src, patch) self.assertEqual(res, dst) + def test_use_replace_instead_of_remove_add_nested(self): + src = {'foo': [{'bar': 1, 'baz': 2}, {'bar': 2, 'baz': 3}]} + dst = {'foo': [{'bar': 1}, {'bar': 2, 'baz': 3}]} + patch = list(jsonpatch.make_patch(src, dst)) + self.assertEqual(len(patch), 1) + self.assertEqual(patch[0]['op'], 'replace') + res = jsonpatch.apply_patch(src, patch) + self.assertEqual(res, dst) + def test_use_move_instead_of_remove_add(self): src = {'foo': [4, 1, 2, 3]} dst = {'foo': [1, 2, 3, 4]} @@ -359,6 +368,29 @@ res = patch.apply(src) self.assertEqual(res, dst) + def test_issue40(self): + """ Tests an issue in _split_by_common_seq reported in #40 """ + + src = [8, 7, 2, 1, 0, 9, 4, 3, 5, 6] + dest = [7, 2, 1, 0, 9, 4, 3, 6, 5, 8] + patch = jsonpatch.make_patch(src, dest) + + def test_minimal_patch(self): + """ Test whether a minimal patch is created, see #36 """ + src = [{"foo": 1, "bar": 2}] + dst = [{"foo": 2, "bar": 2}] + patch = jsonpatch.make_patch(src, dst) + + exp = [ + { + "path": "/0/foo", + "value": 2, + "op": "replace" + } + ] + + self.assertEqual(patch.patch, exp) + class InvalidInputTests(unittest.TestCase): @@ -414,30 +446,30 @@ self.assertRaises(jsonpatch.JsonPatchConflict, jsonpatch.apply_patch, src, patch_obj) - -modules = ['jsonpatch'] +if __name__ == '__main__': + modules = ['jsonpatch'] -def get_suite(): - suite = unittest.TestSuite() - suite.addTest(doctest.DocTestSuite(jsonpatch)) - suite.addTest(unittest.makeSuite(ApplyPatchTestCase)) - suite.addTest(unittest.makeSuite(EqualityTestCase)) - suite.addTest(unittest.makeSuite(MakePatchTestCase)) - suite.addTest(unittest.makeSuite(InvalidInputTests)) - suite.addTest(unittest.makeSuite(ConflictTests)) - return suite + def get_suite(): + suite = unittest.TestSuite() + suite.addTest(doctest.DocTestSuite(jsonpatch)) + suite.addTest(unittest.makeSuite(ApplyPatchTestCase)) + suite.addTest(unittest.makeSuite(EqualityTestCase)) + suite.addTest(unittest.makeSuite(MakePatchTestCase)) + suite.addTest(unittest.makeSuite(InvalidInputTests)) + suite.addTest(unittest.makeSuite(ConflictTests)) + return suite -suite = get_suite() + suite = get_suite() -for module in modules: - m = __import__(module, fromlist=[module]) - suite.addTest(doctest.DocTestSuite(m)) + for module in modules: + m = __import__(module, fromlist=[module]) + suite.addTest(doctest.DocTestSuite(m)) -runner = unittest.TextTestRunner(verbosity=1) + runner = unittest.TextTestRunner(verbosity=1) -result = runner.run(suite) + result = runner.run(suite) -if not result.wasSuccessful(): - sys.exit(1) + if not result.wasSuccessful(): + sys.exit(1)
participants (1)
-
root@hilbert.suse.de