jsonpatch 1.42__py3-none-any.whl → 1.43__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: jsonpatch
3
- Version: 1.42
3
+ Version: 1.43
4
4
  Summary: Apply JSON-Patches (RFC 6902)
5
5
  Home-page: https://github.com/stefankoegl/python-json-patch
6
6
  Author: Stefan Kögl
@@ -0,0 +1,10 @@
1
+ jsonpatch.py,sha256=zvcCUHmwJlvO-N6Us1x9MbFr3yDlAIDwQ9UI9naakRY,58552
2
+ jsonpatch_cli.py,sha256=Vavn3OY4KrowXNTRDbgsNPcd9vTGLkIgz0Hr6Uwr5mk,6480
3
+ jsonpatch-1.43.dist-info/licenses/AUTHORS,sha256=hOtEnBGbfDegKjzMDEl5vuVJyczbI2PlYE2ho4LjGNQ,140
4
+ jsonpatch-1.43.dist-info/licenses/LICENSE,sha256=Q5PrZzP6HjZ_QXabOC9PG-e_Da6x4kPtkrP12Lr9I28,1481
5
+ jsonpatch-stubs/__init__.pyi,sha256=6J9-1EYqLQBCCAuEI7nhIP_DW5zpm3zRWdGMlnFWAqo,5315
6
+ jsonpatch-1.43.dist-info/METADATA,sha256=aP_SW3YwB4xYnasRgvkYbflg12ztJBxX9BQ5VmHH5Ck,4287
7
+ jsonpatch-1.43.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
8
+ jsonpatch-1.43.dist-info/entry_points.txt,sha256=aY9ormBVRZHHDaAeMcdqTBwZ-ax7GvBTSQ33I75xtZM,98
9
+ jsonpatch-1.43.dist-info/top_level.txt,sha256=AGmziZtf5TSFAtbhYlhDGjQg1POmwzF9HwLdbzPkoio,40
10
+ jsonpatch-1.43.dist-info/RECORD,,
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.42'
58
+ __version__ = '1.43'
59
59
  __website__ = 'https://github.com/stefankoegl/python-json-patch'
60
60
  __license__ = 'BSD-3-Clause'
61
61
 
@@ -869,6 +869,9 @@ class JsonPatch(object):
869
869
  one. The resulting patch transforms `src` into `dst`, so it has to be
870
870
  applied to `src` (or to a document equal to it).
871
871
 
872
+ Values in the patch are copied, so changing either input document
873
+ afterwards does not change the generated patch.
874
+
872
875
  :param src: Source JSON document, including arrays and scalar values.
873
876
  :type src: object
874
877
 
@@ -906,7 +909,7 @@ class JsonPatch(object):
906
909
  optimization=optimization,
907
910
  generate_test_ops=generate_test_ops)
908
911
  builder._compare_values((), None, src, dst)
909
- ops = list(builder.execute())
912
+ ops = copy.deepcopy(list(builder.execute()))
910
913
  return cls(ops, pointer_cls=pointer_cls)
911
914
 
912
915
  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
- doc1 = json.load(args.FILE1)
39
- doc2 = json.load(args.FILE2)
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)))
@@ -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,,