jsonpointer 3.4__py3-none-any.whl → 3.6__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.
- {jsonpointer-3.4.data → jsonpointer-3.6.data}/scripts/jsonpointer +13 -3
- {jsonpointer-3.4.dist-info → jsonpointer-3.6.dist-info}/METADATA +1 -1
- jsonpointer-3.6.dist-info/RECORD +8 -0
- {jsonpointer-3.4.dist-info → jsonpointer-3.6.dist-info}/WHEEL +1 -1
- jsonpointer.py +26 -3
- jsonpointer-3.4.dist-info/RECORD +0 -8
- {jsonpointer-3.4.dist-info → jsonpointer-3.6.dist-info}/licenses/AUTHORS +0 -0
- {jsonpointer-3.4.dist-info → jsonpointer-3.6.dist-info}/licenses/LICENSE.txt +0 -0
- {jsonpointer-3.4.dist-info → jsonpointer-3.6.dist-info}/top_level.txt +0 -0
|
@@ -13,7 +13,7 @@ parser = argparse.ArgumentParser(
|
|
|
13
13
|
# Accept pointer as option, as file or as first positional argument
|
|
14
14
|
ptr_group = parser.add_mutually_exclusive_group()
|
|
15
15
|
|
|
16
|
-
ptr_group.add_argument('-f', '--pointer-file', type=argparse.FileType('r'),
|
|
16
|
+
ptr_group.add_argument('-f', '--pointer-file', type=argparse.FileType('r', encoding='utf-8'),
|
|
17
17
|
help='File containing a JSON pointer expression')
|
|
18
18
|
|
|
19
19
|
ptr_group.add_argument('-p', '--pointer', type=str,
|
|
@@ -58,7 +58,11 @@ def parse_pointer(args):
|
|
|
58
58
|
ptr = args.pointer
|
|
59
59
|
else:
|
|
60
60
|
# 2026-10-11: Trim file line endings without changing member names.
|
|
61
|
-
|
|
61
|
+
try:
|
|
62
|
+
ptr = args.pointer_file.read().rstrip("\r\n")
|
|
63
|
+
finally:
|
|
64
|
+
if args.pointer_file is not sys.stdin:
|
|
65
|
+
args.pointer_file.close()
|
|
62
66
|
|
|
63
67
|
elif args.POINTER is not None:
|
|
64
68
|
ptr = args.POINTER
|
|
@@ -88,7 +92,7 @@ def resolve_files():
|
|
|
88
92
|
|
|
89
93
|
for name in files:
|
|
90
94
|
try:
|
|
91
|
-
f = argparse.FileType('r')(name)
|
|
95
|
+
f = argparse.FileType('r', encoding='utf-8')(name)
|
|
92
96
|
except argparse.ArgumentTypeError as e:
|
|
93
97
|
parser.error(str(e))
|
|
94
98
|
|
|
@@ -101,9 +105,15 @@ def resolve_files():
|
|
|
101
105
|
file=sys.stderr)
|
|
102
106
|
ok = False
|
|
103
107
|
continue
|
|
108
|
+
finally:
|
|
109
|
+
if f is not sys.stdin:
|
|
110
|
+
f.close()
|
|
104
111
|
|
|
105
112
|
try:
|
|
106
113
|
result = jsonpointer.resolve_pointer(doc, ptr)
|
|
114
|
+
if isinstance(result, jsonpointer.EndOfList):
|
|
115
|
+
raise jsonpointer.JsonPointerException(
|
|
116
|
+
"'-' does not reference an existing array element")
|
|
107
117
|
print(json.dumps(result, indent=args.indent))
|
|
108
118
|
except jsonpointer.JsonPointerException as e:
|
|
109
119
|
print('Could not resolve pointer: %s' % str(e), file=sys.stderr)
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
jsonpointer.py,sha256=S_EH4YSYOCm-XgxgOKkXQOdUfoEO8QipBeAHVSAtIsk,14476
|
|
2
|
+
jsonpointer-3.6.data/scripts/jsonpointer,sha256=GDB7wGk7t_YNNuiUhRXKruV6LvlS-IlH1JnCHwRPtfo,3988
|
|
3
|
+
jsonpointer-3.6.dist-info/licenses/AUTHORS,sha256=TVgxnQ9ZyHvvWwez_k2w8ZwtfVVFsDTGv3tXyJu-9X8,113
|
|
4
|
+
jsonpointer-3.6.dist-info/licenses/LICENSE.txt,sha256=2LJPFdRyiF94ii1umFhQ8mRie4YBKhe7JCyD8xDZB-U,1413
|
|
5
|
+
jsonpointer-3.6.dist-info/METADATA,sha256=c7vyBJycllBe_KYnhzOPiOIazmFWUshdB5MKNPgdcl0,2638
|
|
6
|
+
jsonpointer-3.6.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
7
|
+
jsonpointer-3.6.dist-info/top_level.txt,sha256=BsUcar_C0nZzPGV2ackrJ9CpVU8_0W_pHYKwpdnWddM,12
|
|
8
|
+
jsonpointer-3.6.dist-info/RECORD,,
|
jsonpointer.py
CHANGED
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
|
|
33
33
|
# Will be parsed by setup.py to determine package metadata
|
|
34
34
|
__author__ = 'Stefan Kögl <stefan@skoegl.net>'
|
|
35
|
-
__version__ = '3.
|
|
35
|
+
__version__ = '3.6'
|
|
36
36
|
__website__ = 'https://github.com/stefankoegl/python-json-pointer'
|
|
37
37
|
__license__ = 'Modified BSD License'
|
|
38
38
|
|
|
@@ -349,11 +349,34 @@ class JsonPointer:
|
|
|
349
349
|
raise JsonPointerException("member '%s' not found" % (part,))
|
|
350
350
|
|
|
351
351
|
def contains(self, ptr):
|
|
352
|
-
"""
|
|
352
|
+
"""Returns True if ptr's parts are a prefix of this pointer's parts.
|
|
353
|
+
|
|
354
|
+
Equal pointers and the root pointer are also prefixes. For example,
|
|
355
|
+
the longer pointer calls contains() with its parent:
|
|
356
|
+
|
|
357
|
+
>>> child = JsonPointer('/foo/bar')
|
|
358
|
+
>>> parent = JsonPointer('/foo')
|
|
359
|
+
>>> child.contains(parent)
|
|
360
|
+
True
|
|
361
|
+
>>> parent.contains(child)
|
|
362
|
+
False
|
|
363
|
+
>>> child.contains(child)
|
|
364
|
+
True
|
|
365
|
+
>>> child.contains(JsonPointer(''))
|
|
366
|
+
True
|
|
367
|
+
>>> child.contains(JsonPointer('/foo/b'))
|
|
368
|
+
False
|
|
369
|
+
"""
|
|
353
370
|
return self.parts[:len(ptr.parts)] == ptr.parts
|
|
354
371
|
|
|
355
372
|
def __contains__(self, item):
|
|
356
|
-
"""
|
|
373
|
+
"""Equivalent to contains(): item must be a prefix of self.
|
|
374
|
+
|
|
375
|
+
>>> JsonPointer('/foo') in JsonPointer('/foo/bar')
|
|
376
|
+
True
|
|
377
|
+
>>> JsonPointer('/foo/bar') in JsonPointer('/foo')
|
|
378
|
+
False
|
|
379
|
+
"""
|
|
357
380
|
return self.contains(item)
|
|
358
381
|
|
|
359
382
|
def join(self, suffix):
|
jsonpointer-3.4.dist-info/RECORD
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
jsonpointer.py,sha256=HRi-qytUqsZMCDOUDddMQC4qojDzk75X0PUZZfz20U4,13792
|
|
2
|
-
jsonpointer-3.4.data/scripts/jsonpointer,sha256=aMNUGc0Tro2UnAFF_k3NKKnOovSVBJ8ZOpigcaow97M,3545
|
|
3
|
-
jsonpointer-3.4.dist-info/licenses/AUTHORS,sha256=TVgxnQ9ZyHvvWwez_k2w8ZwtfVVFsDTGv3tXyJu-9X8,113
|
|
4
|
-
jsonpointer-3.4.dist-info/licenses/LICENSE.txt,sha256=2LJPFdRyiF94ii1umFhQ8mRie4YBKhe7JCyD8xDZB-U,1413
|
|
5
|
-
jsonpointer-3.4.dist-info/METADATA,sha256=bVrbJCJq3CdnPkG40Lb9IvATuFjOxqeigYRUByV97dU,2638
|
|
6
|
-
jsonpointer-3.4.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
|
|
7
|
-
jsonpointer-3.4.dist-info/top_level.txt,sha256=BsUcar_C0nZzPGV2ackrJ9CpVU8_0W_pHYKwpdnWddM,12
|
|
8
|
-
jsonpointer-3.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|