jsonpatch 1.35__py3-none-any.whl → 1.36__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {jsonpatch-1.35.dist-info → jsonpatch-1.36.dist-info}/METADATA +1 -1
- jsonpatch-1.36.dist-info/RECORD +9 -0
- jsonpatch.py +14 -3
- jsonpatch_cli.py +6 -7
- jsonpatch-1.35.dist-info/RECORD +0 -9
- {jsonpatch-1.35.dist-info → jsonpatch-1.36.dist-info}/WHEEL +0 -0
- {jsonpatch-1.35.dist-info → jsonpatch-1.36.dist-info}/entry_points.txt +0 -0
- {jsonpatch-1.35.dist-info → jsonpatch-1.36.dist-info}/licenses/AUTHORS +0 -0
- {jsonpatch-1.35.dist-info → jsonpatch-1.36.dist-info}/licenses/LICENSE +0 -0
- {jsonpatch-1.35.dist-info → jsonpatch-1.36.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
jsonpatch.py,sha256=zlmSJbQUudEtW-I7qw-sit7E5KyEMm_MMYFDEx2JyDo,43250
|
|
2
|
+
jsonpatch_cli.py,sha256=-jUMm0QA5Z13bf2C3uLfZe7YH-vxqbGeDltZ9zd4K4I,5240
|
|
3
|
+
jsonpatch-1.36.dist-info/licenses/AUTHORS,sha256=hOtEnBGbfDegKjzMDEl5vuVJyczbI2PlYE2ho4LjGNQ,140
|
|
4
|
+
jsonpatch-1.36.dist-info/licenses/LICENSE,sha256=Q5PrZzP6HjZ_QXabOC9PG-e_Da6x4kPtkrP12Lr9I28,1481
|
|
5
|
+
jsonpatch-1.36.dist-info/METADATA,sha256=EAKYkquXqZWRxQB-ejAILD8eEk2l5U-1bk8AcilDNoM,3672
|
|
6
|
+
jsonpatch-1.36.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
|
|
7
|
+
jsonpatch-1.36.dist-info/entry_points.txt,sha256=aY9ormBVRZHHDaAeMcdqTBwZ-ax7GvBTSQ33I75xtZM,98
|
|
8
|
+
jsonpatch-1.36.dist-info/top_level.txt,sha256=efUF341HUk8WcQKnFt8ZLKEKNrm1kFT76Flr38Fjno0,24
|
|
9
|
+
jsonpatch-1.36.dist-info/RECORD,,
|
jsonpatch.py
CHANGED
|
@@ -54,7 +54,7 @@ _EXACT_MATCH_LIMIT = 500 ** 2
|
|
|
54
54
|
|
|
55
55
|
# Will be parsed by setup.py to determine package metadata
|
|
56
56
|
__author__ = 'Stefan Kögl <stefan@skoegl.net>'
|
|
57
|
-
__version__ = '1.
|
|
57
|
+
__version__ = '1.36'
|
|
58
58
|
__website__ = 'https://github.com/stefankoegl/python-json-patch'
|
|
59
59
|
__license__ = 'BSD-3-Clause'
|
|
60
60
|
|
|
@@ -597,6 +597,10 @@ class JsonPatch(object):
|
|
|
597
597
|
:param dst: Data target document object.
|
|
598
598
|
:type dst: dict
|
|
599
599
|
|
|
600
|
+
:param optimization: Generate move operations for matching values.
|
|
601
|
+
Set to False to use only add, remove and replace.
|
|
602
|
+
:type optimization: bool
|
|
603
|
+
|
|
600
604
|
:param dumps: A function of one argument that produces a serialized
|
|
601
605
|
JSON string.
|
|
602
606
|
:type dumps: Callable
|
|
@@ -614,7 +618,8 @@ class JsonPatch(object):
|
|
|
614
618
|
True
|
|
615
619
|
"""
|
|
616
620
|
json_dumper = dumps or cls.json_dumper
|
|
617
|
-
builder = DiffBuilder(src, dst, json_dumper, pointer_cls=pointer_cls
|
|
621
|
+
builder = DiffBuilder(src, dst, json_dumper, pointer_cls=pointer_cls,
|
|
622
|
+
optimization=optimization)
|
|
618
623
|
builder._compare_values((), None, src, dst)
|
|
619
624
|
ops = list(builder.execute())
|
|
620
625
|
return cls(ops, pointer_cls=pointer_cls)
|
|
@@ -670,9 +675,11 @@ class JsonPatch(object):
|
|
|
670
675
|
|
|
671
676
|
class DiffBuilder(object):
|
|
672
677
|
|
|
673
|
-
def __init__(self, src_doc, dst_doc, dumps=json.dumps, pointer_cls=JsonPointer
|
|
678
|
+
def __init__(self, src_doc, dst_doc, dumps=json.dumps, pointer_cls=JsonPointer,
|
|
679
|
+
optimization=True):
|
|
674
680
|
self.dumps = dumps
|
|
675
681
|
self.pointer_cls = pointer_cls
|
|
682
|
+
self.optimization = optimization
|
|
676
683
|
self.index_storage = [{}, {}]
|
|
677
684
|
self.__root = root = []
|
|
678
685
|
self.src_doc = src_doc
|
|
@@ -693,10 +700,14 @@ class DiffBuilder(object):
|
|
|
693
700
|
return id(value)
|
|
694
701
|
|
|
695
702
|
def store_index(self, value, index, st):
|
|
703
|
+
if not self.optimization:
|
|
704
|
+
return
|
|
696
705
|
storage = self.index_storage[st]
|
|
697
706
|
storage.setdefault(self._move_key(value), []).append(index)
|
|
698
707
|
|
|
699
708
|
def take_index(self, value, st):
|
|
709
|
+
if not self.optimization:
|
|
710
|
+
return None
|
|
700
711
|
stored = self.index_storage[st].get(self._move_key(value))
|
|
701
712
|
if stored:
|
|
702
713
|
return stored.pop()
|
jsonpatch_cli.py
CHANGED
|
@@ -126,12 +126,11 @@ def patch_files():
|
|
|
126
126
|
if args.backup:
|
|
127
127
|
os.link(args.ORIGINAL.name, args.ORIGINAL.name + '.orig')
|
|
128
128
|
os.chmod(pathname, os.stat(args.ORIGINAL.name).st_mode)
|
|
129
|
-
os.
|
|
129
|
+
os.replace(pathname, args.ORIGINAL.name)
|
|
130
130
|
|
|
131
131
|
except OSError:
|
|
132
|
-
#
|
|
133
|
-
# replace
|
|
134
|
-
#
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
os.rename(pathname, args.ORIGINAL.name)
|
|
132
|
+
# Preserve the original if backup, permissions, or replacement
|
|
133
|
+
# fails. replace() can overwrite an existing file on Windows
|
|
134
|
+
# without unlinking it first.
|
|
135
|
+
os.unlink(pathname)
|
|
136
|
+
raise
|
jsonpatch-1.35.dist-info/RECORD
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
jsonpatch.py,sha256=fO9Isq-oqu2Ua64PLMzuV3wCVIrx0SW7v9xB84W44rA,42817
|
|
2
|
-
jsonpatch_cli.py,sha256=HD5iqPJP__uTPKm50eg7xbTaTuQHL4Bt7MpgO-vlzaM,5304
|
|
3
|
-
jsonpatch-1.35.dist-info/licenses/AUTHORS,sha256=hOtEnBGbfDegKjzMDEl5vuVJyczbI2PlYE2ho4LjGNQ,140
|
|
4
|
-
jsonpatch-1.35.dist-info/licenses/LICENSE,sha256=Q5PrZzP6HjZ_QXabOC9PG-e_Da6x4kPtkrP12Lr9I28,1481
|
|
5
|
-
jsonpatch-1.35.dist-info/METADATA,sha256=v3G9IpDxUG83tcXWWPX4CQlfs4lMll0QGIw2i9qfDMM,3672
|
|
6
|
-
jsonpatch-1.35.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
|
|
7
|
-
jsonpatch-1.35.dist-info/entry_points.txt,sha256=aY9ormBVRZHHDaAeMcdqTBwZ-ax7GvBTSQ33I75xtZM,98
|
|
8
|
-
jsonpatch-1.35.dist-info/top_level.txt,sha256=efUF341HUk8WcQKnFt8ZLKEKNrm1kFT76Flr38Fjno0,24
|
|
9
|
-
jsonpatch-1.35.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|