jsonpointer 2.4__tar.gz → 3.0.0__tar.gz

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,31 +1,29 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: jsonpointer
3
- Version: 2.4
3
+ Version: 3.0.0
4
4
  Summary: Identify specific nodes in a JSON document (RFC 6901)
5
5
  Home-page: https://github.com/stefankoegl/python-json-pointer
6
6
  Author: Stefan Kögl
7
7
  Author-email: stefan@skoegl.net
8
8
  License: Modified BSD License
9
- Platform: UNKNOWN
10
9
  Classifier: Development Status :: 5 - Production/Stable
11
10
  Classifier: Environment :: Console
12
11
  Classifier: Intended Audience :: Developers
13
12
  Classifier: License :: OSI Approved :: BSD License
14
13
  Classifier: Operating System :: OS Independent
15
14
  Classifier: Programming Language :: Python
16
- Classifier: Programming Language :: Python :: 2
17
- Classifier: Programming Language :: Python :: 2.7
18
15
  Classifier: Programming Language :: Python :: 3
19
16
  Classifier: Programming Language :: Python :: 3.7
20
17
  Classifier: Programming Language :: Python :: 3.8
21
18
  Classifier: Programming Language :: Python :: 3.9
22
19
  Classifier: Programming Language :: Python :: 3.10
23
20
  Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
24
22
  Classifier: Programming Language :: Python :: Implementation :: CPython
25
23
  Classifier: Programming Language :: Python :: Implementation :: PyPy
26
24
  Classifier: Topic :: Software Development :: Libraries
27
25
  Classifier: Topic :: Utilities
28
- Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*, !=3.6.*
26
+ Requires-Python: >=3.7
29
27
  Description-Content-Type: text/markdown
30
28
  License-File: LICENSE.txt
31
29
  License-File: AUTHORS
@@ -35,7 +33,6 @@ python-json-pointer
35
33
 
36
34
  [![PyPI version](https://img.shields.io/pypi/v/jsonpointer.svg)](https://pypi.python.org/pypi/jsonpointer/)
37
35
  [![Supported Python versions](https://img.shields.io/pypi/pyversions/jsonpointer.svg)](https://pypi.python.org/pypi/jsonpointer/)
38
- [![Build Status](https://travis-ci.org/stefankoegl/python-json-pointer.svg?branch=master)](https://travis-ci.org/stefankoegl/python-json-pointer)
39
36
  [![Coverage Status](https://coveralls.io/repos/stefankoegl/python-json-pointer/badge.svg?branch=master)](https://coveralls.io/r/stefankoegl/python-json-pointer?branch=master)
40
37
 
41
38
 
@@ -52,5 +49,3 @@ See source code for examples
52
49
  * PyPI: https://pypi.python.org/pypi/jsonpointer
53
50
  * Travis CI: https://travis-ci.org/stefankoegl/python-json-pointer
54
51
  * Coveralls: https://coveralls.io/r/stefankoegl/python-json-pointer
55
-
56
-
@@ -3,7 +3,6 @@ python-json-pointer
3
3
 
4
4
  [![PyPI version](https://img.shields.io/pypi/v/jsonpointer.svg)](https://pypi.python.org/pypi/jsonpointer/)
5
5
  [![Supported Python versions](https://img.shields.io/pypi/pyversions/jsonpointer.svg)](https://pypi.python.org/pypi/jsonpointer/)
6
- [![Build Status](https://travis-ci.org/stefankoegl/python-json-pointer.svg?branch=master)](https://travis-ci.org/stefankoegl/python-json-pointer)
7
6
  [![Coverage Status](https://coveralls.io/repos/stefankoegl/python-json-pointer/badge.svg?branch=master)](https://coveralls.io/r/stefankoegl/python-json-pointer?branch=master)
8
7
 
9
8
 
@@ -1,14 +1,12 @@
1
1
  #!/usr/bin/env python
2
2
  # -*- coding: utf-8 -*-
3
3
 
4
- from __future__ import print_function
5
4
 
6
- import sys
7
- import os.path
8
- import json
9
- import jsonpointer
10
5
  import argparse
6
+ import json
7
+ import sys
11
8
 
9
+ import jsonpointer
12
10
 
13
11
  parser = argparse.ArgumentParser(
14
12
  description='Resolve a JSON pointer on JSON files')
@@ -20,7 +18,7 @@ ptr_group.add_argument('-f', '--pointer-file', type=argparse.FileType('r'),
20
18
  nargs='?',
21
19
  help='File containing a JSON pointer expression')
22
20
 
23
- ptr_group.add_argument('POINTER', type=str, nargs='?',
21
+ ptr_group.add_argument('POINTER', type=str, nargs='?',
24
22
  help='A JSON pointer expression')
25
23
 
26
24
  parser.add_argument('FILE', type=argparse.FileType('r'), nargs='+',
@@ -1,31 +1,29 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: jsonpointer
3
- Version: 2.4
3
+ Version: 3.0.0
4
4
  Summary: Identify specific nodes in a JSON document (RFC 6901)
5
5
  Home-page: https://github.com/stefankoegl/python-json-pointer
6
6
  Author: Stefan Kögl
7
7
  Author-email: stefan@skoegl.net
8
8
  License: Modified BSD License
9
- Platform: UNKNOWN
10
9
  Classifier: Development Status :: 5 - Production/Stable
11
10
  Classifier: Environment :: Console
12
11
  Classifier: Intended Audience :: Developers
13
12
  Classifier: License :: OSI Approved :: BSD License
14
13
  Classifier: Operating System :: OS Independent
15
14
  Classifier: Programming Language :: Python
16
- Classifier: Programming Language :: Python :: 2
17
- Classifier: Programming Language :: Python :: 2.7
18
15
  Classifier: Programming Language :: Python :: 3
19
16
  Classifier: Programming Language :: Python :: 3.7
20
17
  Classifier: Programming Language :: Python :: 3.8
21
18
  Classifier: Programming Language :: Python :: 3.9
22
19
  Classifier: Programming Language :: Python :: 3.10
23
20
  Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
24
22
  Classifier: Programming Language :: Python :: Implementation :: CPython
25
23
  Classifier: Programming Language :: Python :: Implementation :: PyPy
26
24
  Classifier: Topic :: Software Development :: Libraries
27
25
  Classifier: Topic :: Utilities
28
- Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*, !=3.6.*
26
+ Requires-Python: >=3.7
29
27
  Description-Content-Type: text/markdown
30
28
  License-File: LICENSE.txt
31
29
  License-File: AUTHORS
@@ -35,7 +33,6 @@ python-json-pointer
35
33
 
36
34
  [![PyPI version](https://img.shields.io/pypi/v/jsonpointer.svg)](https://pypi.python.org/pypi/jsonpointer/)
37
35
  [![Supported Python versions](https://img.shields.io/pypi/pyversions/jsonpointer.svg)](https://pypi.python.org/pypi/jsonpointer/)
38
- [![Build Status](https://travis-ci.org/stefankoegl/python-json-pointer.svg?branch=master)](https://travis-ci.org/stefankoegl/python-json-pointer)
39
36
  [![Coverage Status](https://coveralls.io/repos/stefankoegl/python-json-pointer/badge.svg?branch=master)](https://coveralls.io/r/stefankoegl/python-json-pointer?branch=master)
40
37
 
41
38
 
@@ -52,5 +49,3 @@ See source code for examples
52
49
  * PyPI: https://pypi.python.org/pypi/jsonpointer
53
50
  * Travis CI: https://travis-ci.org/stefankoegl/python-json-pointer
54
51
  * Coveralls: https://coveralls.io/r/stefankoegl/python-json-pointer
55
-
56
-
@@ -32,38 +32,22 @@
32
32
 
33
33
  """ Identify specific nodes in a JSON document (RFC 6901) """
34
34
 
35
- from __future__ import unicode_literals
36
-
37
35
  # Will be parsed by setup.py to determine package metadata
38
36
  __author__ = 'Stefan Kögl <stefan@skoegl.net>'
39
- __version__ = '2.4'
37
+ __version__ = '3.0.0'
40
38
  __website__ = 'https://github.com/stefankoegl/python-json-pointer'
41
39
  __license__ = 'Modified BSD License'
42
40
 
43
-
44
- try:
45
- from itertools import izip
46
- str = unicode
47
- encode_str = lambda u: u.encode("raw_unicode_escape")
48
- except ImportError: # Python 3
49
- izip = zip
50
- encode_str = lambda u: u
51
-
52
- try:
53
- from collections.abc import Mapping, Sequence
54
- except ImportError: # Python 3
55
- from collections import Mapping, Sequence
56
-
57
- from itertools import tee, chain
58
- import re
59
41
  import copy
60
-
42
+ import re
43
+ from collections.abc import Mapping, Sequence
44
+ from itertools import tee, chain
61
45
 
62
46
  _nothing = object()
63
47
 
64
48
 
65
49
  def set_pointer(doc, pointer, value, inplace=True):
66
- """Resolves pointer against doc and sets the value of the target within doc.
50
+ """Resolves a pointer against doc and sets the value of the target within doc.
67
51
 
68
52
  With inplace set to true, doc is modified as long as pointer is not the
69
53
  root.
@@ -145,7 +129,7 @@ def pairwise(iterable):
145
129
  a, b = tee(iterable)
146
130
  for _ in b:
147
131
  break
148
- return izip(a, b)
132
+ return zip(a, b)
149
133
 
150
134
 
151
135
  class JsonPointerException(Exception):
@@ -259,12 +243,11 @@ class JsonPointer(object):
259
243
  else:
260
244
  raise JsonPointerException("Document '%s' does not support indexing, "
261
245
  "must be mapping/sequence or support __getitem__" % type(doc))
262
-
246
+
263
247
  def get_parts(self):
264
248
  """Returns the list of the parts. For example, JsonPointer('/a/b').get_parts() == ['a', 'b']"""
265
-
266
- return self.parts
267
249
 
250
+ return self.parts
268
251
 
269
252
  def walk(self, doc, part):
270
253
  """ Walks one step in doc and returns the referenced part """
@@ -281,7 +264,7 @@ class JsonPointer(object):
281
264
  return doc[part]
282
265
 
283
266
  except IndexError:
284
- raise JsonPointerException("index '%s' is out of bounds" % (part, ))
267
+ raise JsonPointerException("index '%s' is out of bounds" % (part,))
285
268
 
286
269
  # Else the object is a mapping or supports __getitem__(so assume custom indexing)
287
270
  try:
@@ -290,7 +273,6 @@ class JsonPointer(object):
290
273
  except KeyError:
291
274
  raise JsonPointerException("member '%s' not found in %s" % (part, doc))
292
275
 
293
-
294
276
  def contains(self, ptr):
295
277
  """ Returns True if self contains the given ptr """
296
278
  return self.parts[:len(ptr.parts)] == ptr.parts
@@ -309,12 +291,11 @@ class JsonPointer(object):
309
291
  suffix_parts = suffix
310
292
  try:
311
293
  return JsonPointer.from_parts(chain(self.parts, suffix_parts))
312
- except:
294
+ except: # noqa E722
313
295
  raise JsonPointerException("Invalid suffix")
314
296
 
315
- def __truediv__(self, suffix): # Python 3
297
+ def __truediv__(self, suffix): # Python 3
316
298
  return self.join(suffix)
317
- __div__ = __truediv__ # Python 2
318
299
 
319
300
  @property
320
301
  def path(self):
@@ -342,10 +323,10 @@ class JsonPointer(object):
342
323
  return hash(tuple(self.parts))
343
324
 
344
325
  def __str__(self):
345
- return encode_str(self.path)
326
+ return self.path
346
327
 
347
328
  def __repr__(self):
348
- return "JsonPointer(" + repr(self.path) + ")"
329
+ return type(self).__name__ + "(" + repr(self.path) + ")"
349
330
 
350
331
  @classmethod
351
332
  def from_parts(cls, parts):
@@ -362,5 +343,6 @@ class JsonPointer(object):
362
343
  def escape(s):
363
344
  return s.replace('~', '~0').replace('/', '~1')
364
345
 
346
+
365
347
  def unescape(s):
366
348
  return s.replace('~1', '/').replace('~0', '~')
@@ -0,0 +1,11 @@
1
+ [bdist_wheel]
2
+ universal = 1
3
+
4
+ [flake8]
5
+ max-line-length = 120
6
+ exclude = .git,.tox,dist,doc,*egg,build,.venv
7
+
8
+ [egg_info]
9
+ tag_build =
10
+ tag_date = 0
11
+
@@ -1,9 +1,10 @@
1
1
  #!/usr/bin/env python
2
2
 
3
- from setuptools import setup
4
- import re
5
3
  import io
6
4
  import os.path
5
+ import re
6
+
7
+ from setuptools import setup
7
8
 
8
9
  dirname = os.path.dirname(os.path.abspath(__file__))
9
10
  filename = os.path.join(dirname, 'jsonpointer.py')
@@ -14,7 +15,7 @@ docstrings = re.findall('"""(.*)"""', src)
14
15
  PACKAGE = 'jsonpointer'
15
16
 
16
17
  MODULES = (
17
- 'jsonpointer',
18
+ 'jsonpointer',
18
19
  )
19
20
 
20
21
  AUTHOR_EMAIL = metadata['author']
@@ -26,10 +27,8 @@ DESCRIPTION = docstrings[0]
26
27
  # Extract name and e-mail ("Firstname Lastname <mail@example.org>")
27
28
  AUTHOR, EMAIL = re.match(r'(.*) <(.*)>', AUTHOR_EMAIL).groups()
28
29
 
29
-
30
30
  with open('README.md') as readme:
31
- long_description = readme.read()
32
-
31
+ long_description = readme.read()
33
32
 
34
33
  CLASSIFIERS = [
35
34
  'Development Status :: 5 - Production/Stable',
@@ -38,14 +37,13 @@ CLASSIFIERS = [
38
37
  'License :: OSI Approved :: BSD License',
39
38
  'Operating System :: OS Independent',
40
39
  'Programming Language :: Python',
41
- 'Programming Language :: Python :: 2',
42
- 'Programming Language :: Python :: 2.7',
43
40
  'Programming Language :: Python :: 3',
44
41
  'Programming Language :: Python :: 3.7',
45
42
  'Programming Language :: Python :: 3.8',
46
43
  'Programming Language :: Python :: 3.9',
47
44
  'Programming Language :: Python :: 3.10',
48
45
  'Programming Language :: Python :: 3.11',
46
+ 'Programming Language :: Python :: 3.12',
49
47
  'Programming Language :: Python :: Implementation :: CPython',
50
48
  'Programming Language :: Python :: Implementation :: PyPy',
51
49
  'Topic :: Software Development :: Libraries',
@@ -64,5 +62,5 @@ setup(name=PACKAGE,
64
62
  py_modules=MODULES,
65
63
  scripts=['bin/jsonpointer'],
66
64
  classifiers=CLASSIFIERS,
67
- python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*, !=3.6.*',
68
- )
65
+ python_requires='>=3.7',
66
+ )
@@ -3,20 +3,21 @@
3
3
 
4
4
  from __future__ import unicode_literals
5
5
 
6
+ import copy
6
7
  import doctest
7
- import unittest
8
8
  import sys
9
- import copy
9
+ import unittest
10
+
10
11
  import jsonpointer
11
12
  from jsonpointer import resolve_pointer, EndOfList, JsonPointerException, \
12
- JsonPointer, set_pointer
13
+ JsonPointer, set_pointer
13
14
 
14
15
 
15
16
  class SpecificationTests(unittest.TestCase):
16
17
  """ Tests all examples from the JSON Pointer specification """
17
18
 
18
19
  def test_example(self):
19
- doc = {
20
+ doc = {
20
21
  "foo": ["bar", "baz"],
21
22
  "": 0,
22
23
  "a/b": 1,
@@ -42,7 +43,6 @@ class SpecificationTests(unittest.TestCase):
42
43
  self.assertEqual(resolve_pointer(doc, "/ "), 7)
43
44
  self.assertEqual(resolve_pointer(doc, "/m~0n"), 8)
44
45
 
45
-
46
46
  def test_eol(self):
47
47
  doc = {
48
48
  "foo": ["bar", "baz"]
@@ -165,19 +165,16 @@ class ComparisonTests(unittest.TestCase):
165
165
  self.assertFalse(p1 == "/something/1/b")
166
166
 
167
167
  def test_contains(self):
168
-
169
168
  self.assertTrue(self.ptr1.contains(self.ptr2))
170
169
  self.assertTrue(self.ptr1.contains(self.ptr1))
171
170
  self.assertFalse(self.ptr1.contains(self.ptr3))
172
171
 
173
172
  def test_contains_magic(self):
174
-
175
173
  self.assertTrue(self.ptr2 in self.ptr1)
176
174
  self.assertTrue(self.ptr1 in self.ptr1)
177
175
  self.assertFalse(self.ptr3 in self.ptr1)
178
176
 
179
177
  def test_join(self):
180
-
181
178
  ptr12a = self.ptr1.join(self.ptr2)
182
179
  self.assertEqual(ptr12a.path, "/a/b/c/a/b")
183
180
 
@@ -196,7 +193,6 @@ class ComparisonTests(unittest.TestCase):
196
193
  self.assertRaises(JsonPointerException, self.ptr1.join, 0)
197
194
 
198
195
  def test_join_magic(self):
199
-
200
196
  ptr12a = self.ptr1 / self.ptr2
201
197
  self.assertEqual(ptr12a.path, "/a/b/c/a/b")
202
198
 
@@ -212,6 +208,7 @@ class ComparisonTests(unittest.TestCase):
212
208
  ptr12e = self.ptr1 / ["a", "b"]
213
209
  self.assertEqual(ptr12e.path, "/a/b/c/a/b")
214
210
 
211
+
215
212
  class WrongInputTests(unittest.TestCase):
216
213
 
217
214
  def test_no_start_slash(self):
@@ -244,7 +241,6 @@ class ToLastTests(unittest.TestCase):
244
241
  self.assertEqual(doc, last)
245
242
  self.assertTrue(nxt is None)
246
243
 
247
-
248
244
  def test_path(self):
249
245
  doc = {'a': [{'b': 1, 'c': 2}, 5]}
250
246
  ptr = JsonPointer('/a/0/b')
@@ -256,7 +252,7 @@ class ToLastTests(unittest.TestCase):
256
252
  class SetTests(unittest.TestCase):
257
253
 
258
254
  def test_set(self):
259
- doc = {
255
+ doc = {
260
256
  "foo": ["bar", "baz"],
261
257
  "": 0,
262
258
  "a/b": 1,
@@ -285,7 +281,7 @@ class SetTests(unittest.TestCase):
285
281
 
286
282
  newdoc = set_pointer(doc, "/fud", {}, inplace=False)
287
283
  newdoc = set_pointer(newdoc, "/fud/gaw", [1, 2, 3], inplace=False)
288
- self.assertEqual(resolve_pointer(newdoc, "/fud"), {'gaw' : [1, 2, 3]})
284
+ self.assertEqual(resolve_pointer(newdoc, "/fud"), {'gaw': [1, 2, 3]})
289
285
 
290
286
  newdoc = set_pointer(doc, "", 9, inplace=False)
291
287
  self.assertEqual(newdoc, 9)
@@ -307,14 +303,13 @@ class SetTests(unittest.TestCase):
307
303
  self.assertRaises(JsonPointerException, set_pointer, doc, "/fud/gaw", 9)
308
304
 
309
305
  set_pointer(doc, "/fud", {})
310
- set_pointer(doc, "/fud/gaw", [1, 2, 3] )
311
- self.assertEqual(resolve_pointer(doc, "/fud"), {'gaw' : [1, 2, 3]})
306
+ set_pointer(doc, "/fud/gaw", [1, 2, 3])
307
+ self.assertEqual(resolve_pointer(doc, "/fud"), {'gaw': [1, 2, 3]})
312
308
 
313
309
  self.assertRaises(JsonPointerException, set_pointer, doc, "", 9)
314
310
 
315
311
 
316
312
  class AltTypesTests(unittest.TestCase):
317
-
318
313
  class Node(object):
319
314
  def __init__(self, name, parent=None):
320
315
  self.name = name
@@ -349,13 +344,13 @@ class AltTypesTests(unittest.TestCase):
349
344
  class mdict(object):
350
345
  def __init__(self, d):
351
346
  self._d = d
347
+
352
348
  def __getitem__(self, item):
353
349
  return self._d[item]
354
350
 
355
351
  mdict = mdict({'root': {'1': {'2': '3'}}})
356
352
  Node = Node
357
353
 
358
-
359
354
  def test_alttypes(self):
360
355
  Node = self.Node
361
356
 
jsonpointer-2.4/setup.cfg DELETED
@@ -1,7 +0,0 @@
1
- [bdist_wheel]
2
- universal = 1
3
-
4
- [egg_info]
5
- tag_build =
6
- tag_date = 0
7
-
File without changes
File without changes
File without changes