jsonpatch 1.42__py3-none-any.whl → 1.44__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.42.dist-info → jsonpatch-1.44.dist-info}/METADATA +1 -1
- jsonpatch-1.44.dist-info/RECORD +10 -0
- jsonpatch-stubs/__init__.pyi +6 -5
- jsonpatch.py +13 -5
- jsonpatch_cli.py +7 -2
- jsonpatch-1.42.dist-info/RECORD +0 -10
- {jsonpatch-1.42.dist-info → jsonpatch-1.44.dist-info}/WHEEL +0 -0
- {jsonpatch-1.42.dist-info → jsonpatch-1.44.dist-info}/entry_points.txt +0 -0
- {jsonpatch-1.42.dist-info → jsonpatch-1.44.dist-info}/licenses/AUTHORS +0 -0
- {jsonpatch-1.42.dist-info → jsonpatch-1.44.dist-info}/licenses/LICENSE +0 -0
- {jsonpatch-1.42.dist-info → jsonpatch-1.44.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
jsonpatch.py,sha256=4fsloqOO4Bjt2r8KIxdugLC0KYQyrXz3cPeQ2aLPCPU,58897
|
|
2
|
+
jsonpatch_cli.py,sha256=Vavn3OY4KrowXNTRDbgsNPcd9vTGLkIgz0Hr6Uwr5mk,6480
|
|
3
|
+
jsonpatch-1.44.dist-info/licenses/AUTHORS,sha256=hOtEnBGbfDegKjzMDEl5vuVJyczbI2PlYE2ho4LjGNQ,140
|
|
4
|
+
jsonpatch-1.44.dist-info/licenses/LICENSE,sha256=Q5PrZzP6HjZ_QXabOC9PG-e_Da6x4kPtkrP12Lr9I28,1481
|
|
5
|
+
jsonpatch-stubs/__init__.pyi,sha256=5fzpfmr8rAGOlRRwToKtdu7lIh1QMpxql5eEBs1KRKc,5357
|
|
6
|
+
jsonpatch-1.44.dist-info/METADATA,sha256=C2rxMRGT34fBQuy9TzisMaZEQ6rT5d4td4Eofve9q4g,4287
|
|
7
|
+
jsonpatch-1.44.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
8
|
+
jsonpatch-1.44.dist-info/entry_points.txt,sha256=aY9ormBVRZHHDaAeMcdqTBwZ-ax7GvBTSQ33I75xtZM,98
|
|
9
|
+
jsonpatch-1.44.dist-info/top_level.txt,sha256=AGmziZtf5TSFAtbhYlhDGjQg1POmwzF9HwLdbzPkoio,40
|
|
10
|
+
jsonpatch-1.44.dist-info/RECORD,,
|
jsonpatch-stubs/__init__.pyi
CHANGED
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
# also accepts arbitrary Mapping / Sequence types, which a recursive JSON type
|
|
10
10
|
# would reject.
|
|
11
11
|
|
|
12
|
-
from collections.abc import Callable, Iterable, Iterator, Mapping
|
|
12
|
+
from collections.abc import Callable, Iterable, Iterator, Mapping
|
|
13
|
+
from types import MappingProxyType
|
|
13
14
|
from typing import Any, ClassVar
|
|
14
15
|
|
|
15
16
|
# Re-exported, as jsonpatch.py imports them and users rely on that, e.g. to
|
|
@@ -57,7 +58,7 @@ class PatchOperation:
|
|
|
57
58
|
pointer_cls: type[JsonPointer]
|
|
58
59
|
location: str
|
|
59
60
|
pointer: JsonPointer
|
|
60
|
-
operation:
|
|
61
|
+
operation: dict[str, Any]
|
|
61
62
|
def __init__(self, operation: _Operation, pointer_cls: type[JsonPointer] = ...) -> None: ...
|
|
62
63
|
def apply(self, obj: Any) -> Any: ...
|
|
63
64
|
def __hash__(self) -> int: ...
|
|
@@ -92,12 +93,12 @@ class CopyOperation(PatchOperation): ...
|
|
|
92
93
|
class JsonPatch:
|
|
93
94
|
json_dumper: ClassVar[Callable[..., str]]
|
|
94
95
|
json_loader: ClassVar[Callable[..., Any]]
|
|
95
|
-
operations: ClassVar[
|
|
96
|
+
operations: ClassVar[MappingProxyType[str, type[PatchOperation]]]
|
|
96
97
|
pointer_cls: type[JsonPointer]
|
|
97
|
-
patch:
|
|
98
|
+
patch: list[dict[str, Any]]
|
|
98
99
|
def __init__(self, patch: Iterable[_Operation], pointer_cls: type[JsonPointer] = ...) -> None: ...
|
|
99
100
|
def __bool__(self) -> bool: ...
|
|
100
|
-
def __iter__(self) -> Iterator[
|
|
101
|
+
def __iter__(self) -> Iterator[dict[str, Any]]: ...
|
|
101
102
|
def __hash__(self) -> int: ...
|
|
102
103
|
def __eq__(self, other: object) -> bool: ...
|
|
103
104
|
def __ne__(self, other: object) -> bool: ...
|
jsonpatch.py
CHANGED
|
@@ -55,7 +55,7 @@ _EXACT_MATCH_LIMIT = 500 ** 2
|
|
|
55
55
|
|
|
56
56
|
# Will be parsed by setup.py to determine package metadata
|
|
57
57
|
__author__ = 'Stefan Kögl <stefan@skoegl.net>'
|
|
58
|
-
__version__ = '1.
|
|
58
|
+
__version__ = '1.44'
|
|
59
59
|
__website__ = 'https://github.com/stefankoegl/python-json-patch'
|
|
60
60
|
__license__ = 'BSD-3-Clause'
|
|
61
61
|
|
|
@@ -373,7 +373,8 @@ class PatchOperation(object):
|
|
|
373
373
|
except TypeError:
|
|
374
374
|
raise InvalidJsonPatch("Invalid 'path'", op=operation)
|
|
375
375
|
|
|
376
|
-
|
|
376
|
+
# Setters update operation members, even when the input is read-only.
|
|
377
|
+
self.operation = operation if isinstance(operation, dict) else dict(operation)
|
|
377
378
|
|
|
378
379
|
def _from_pointer(self):
|
|
379
380
|
"""Builds the pointer of the 'from' member like __init__ builds the
|
|
@@ -791,7 +792,7 @@ class JsonPatch(object):
|
|
|
791
792
|
if isinstance(patch, (str, bytes, Mapping)):
|
|
792
793
|
raise InvalidJsonPatch("Document is expected to be sequence of operations")
|
|
793
794
|
try:
|
|
794
|
-
self.patch =
|
|
795
|
+
self.patch = list(patch)
|
|
795
796
|
except TypeError:
|
|
796
797
|
raise InvalidJsonPatch("Document is expected to be sequence of operations")
|
|
797
798
|
|
|
@@ -799,7 +800,7 @@ class JsonPatch(object):
|
|
|
799
800
|
# is correct by retrieving each patch element.
|
|
800
801
|
# Much of the validation is done in the initializer
|
|
801
802
|
# though some is delayed until the patch is applied.
|
|
802
|
-
for op in self.patch:
|
|
803
|
+
for index, op in enumerate(self.patch):
|
|
803
804
|
# We're only checking for strings in the following check
|
|
804
805
|
# for two reasons:
|
|
805
806
|
#
|
|
@@ -815,6 +816,10 @@ class JsonPatch(object):
|
|
|
815
816
|
op=op)
|
|
816
817
|
|
|
817
818
|
self._get_operation(op)
|
|
819
|
+
# Keep validation errors tied to the original input, but expose
|
|
820
|
+
# concrete, JSON-serializable operation dictionaries on success.
|
|
821
|
+
if not isinstance(op, dict):
|
|
822
|
+
self.patch[index] = dict(op)
|
|
818
823
|
|
|
819
824
|
def __str__(self):
|
|
820
825
|
"""str(self) -> self.to_string()"""
|
|
@@ -869,6 +874,9 @@ class JsonPatch(object):
|
|
|
869
874
|
one. The resulting patch transforms `src` into `dst`, so it has to be
|
|
870
875
|
applied to `src` (or to a document equal to it).
|
|
871
876
|
|
|
877
|
+
Values in the patch are copied, so changing either input document
|
|
878
|
+
afterwards does not change the generated patch.
|
|
879
|
+
|
|
872
880
|
:param src: Source JSON document, including arrays and scalar values.
|
|
873
881
|
:type src: object
|
|
874
882
|
|
|
@@ -906,7 +914,7 @@ class JsonPatch(object):
|
|
|
906
914
|
optimization=optimization,
|
|
907
915
|
generate_test_ops=generate_test_ops)
|
|
908
916
|
builder._compare_values((), None, src, dst)
|
|
909
|
-
ops = list(builder.execute())
|
|
917
|
+
ops = copy.deepcopy(list(builder.execute()))
|
|
910
918
|
return cls(ops, pointer_cls=pointer_cls)
|
|
911
919
|
|
|
912
920
|
def to_string(self, dumps=None):
|
jsonpatch_cli.py
CHANGED
|
@@ -8,6 +8,7 @@ import json
|
|
|
8
8
|
import jsonpatch
|
|
9
9
|
import tempfile
|
|
10
10
|
import argparse
|
|
11
|
+
from contextlib import ExitStack
|
|
11
12
|
|
|
12
13
|
|
|
13
14
|
jsondiff_parser = argparse.ArgumentParser(
|
|
@@ -35,8 +36,12 @@ def jsondiff_main():
|
|
|
35
36
|
def diff_files():
|
|
36
37
|
""" Diffs two JSON files and prints a patch """
|
|
37
38
|
args = jsondiff_parser.parse_args()
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
with ExitStack() as inputs:
|
|
40
|
+
for stream in (args.FILE1, args.FILE2):
|
|
41
|
+
if stream is not sys.stdin:
|
|
42
|
+
inputs.enter_context(stream)
|
|
43
|
+
doc1 = json.load(args.FILE1)
|
|
44
|
+
doc2 = json.load(args.FILE2)
|
|
40
45
|
patch = jsonpatch.make_patch(doc1, doc2, generate_test_ops=args.test_ops)
|
|
41
46
|
if patch.patch:
|
|
42
47
|
print(json.dumps(patch.patch, indent=args.indent, ensure_ascii=not(args.preserve_unicode)))
|
jsonpatch-1.42.dist-info/RECORD
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
jsonpatch.py,sha256=bf7jUUmYBd6LxV4ZQ8pYM_5GL2QtfJJoIbcR0QWpOTw,58406
|
|
2
|
-
jsonpatch_cli.py,sha256=ooxDB62_Vcx6ryCbyMHItkNgmZjp73ZOyxgV1IAcdVI,6274
|
|
3
|
-
jsonpatch-1.42.dist-info/licenses/AUTHORS,sha256=hOtEnBGbfDegKjzMDEl5vuVJyczbI2PlYE2ho4LjGNQ,140
|
|
4
|
-
jsonpatch-1.42.dist-info/licenses/LICENSE,sha256=Q5PrZzP6HjZ_QXabOC9PG-e_Da6x4kPtkrP12Lr9I28,1481
|
|
5
|
-
jsonpatch-stubs/__init__.pyi,sha256=6J9-1EYqLQBCCAuEI7nhIP_DW5zpm3zRWdGMlnFWAqo,5315
|
|
6
|
-
jsonpatch-1.42.dist-info/METADATA,sha256=zVFI0HoZ3yJ_VWdH46l49zR5OIrziG2liD_8PdMHxvA,4287
|
|
7
|
-
jsonpatch-1.42.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
8
|
-
jsonpatch-1.42.dist-info/entry_points.txt,sha256=aY9ormBVRZHHDaAeMcdqTBwZ-ax7GvBTSQ33I75xtZM,98
|
|
9
|
-
jsonpatch-1.42.dist-info/top_level.txt,sha256=AGmziZtf5TSFAtbhYlhDGjQg1POmwzF9HwLdbzPkoio,40
|
|
10
|
-
jsonpatch-1.42.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|