json-stream 2.3.2__tar.gz → 2.3.3__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.
- {json-stream-2.3.2/src/json_stream.egg-info → json_stream-2.3.3}/PKG-INFO +8 -4
- {json-stream-2.3.2 → json_stream-2.3.3}/pyproject.toml +3 -2
- {json-stream-2.3.2 → json_stream-2.3.3}/src/json_stream/base.py +5 -1
- {json-stream-2.3.2 → json_stream-2.3.3}/src/json_stream/tests/test_buffering.py +2 -11
- json_stream-2.3.3/src/json_stream/tests/test_collection_abcs.py +17 -0
- {json-stream-2.3.2 → json_stream-2.3.3}/src/json_stream/tests/test_tokenizer_integration.py +0 -12
- {json-stream-2.3.2 → json_stream-2.3.3}/src/json_stream/tests/test_writer.py +19 -11
- {json-stream-2.3.2 → json_stream-2.3.3}/src/json_stream/writer.py +6 -2
- {json-stream-2.3.2 → json_stream-2.3.3/src/json_stream.egg-info}/PKG-INFO +8 -4
- {json-stream-2.3.2 → json_stream-2.3.3}/src/json_stream.egg-info/SOURCES.txt +1 -0
- {json-stream-2.3.2 → json_stream-2.3.3}/LICENSE.txt +0 -0
- {json-stream-2.3.2 → json_stream-2.3.3}/README.md +0 -0
- {json-stream-2.3.2 → json_stream-2.3.3}/setup.cfg +0 -0
- {json-stream-2.3.2 → json_stream-2.3.3}/src/json_stream/__init__.py +0 -0
- {json-stream-2.3.2 → json_stream-2.3.3}/src/json_stream/dump/__init__.py +0 -0
- {json-stream-2.3.2 → json_stream-2.3.3}/src/json_stream/dump/tests/__init__.py +0 -0
- {json-stream-2.3.2 → json_stream-2.3.3}/src/json_stream/dump/tests/test_dump.py +0 -0
- {json-stream-2.3.2 → json_stream-2.3.3}/src/json_stream/dump/threading.py +0 -0
- {json-stream-2.3.2 → json_stream-2.3.3}/src/json_stream/httpx/__init__.py +0 -0
- {json-stream-2.3.2 → json_stream-2.3.3}/src/json_stream/httpx/tests/__init__.py +0 -0
- {json-stream-2.3.2 → json_stream-2.3.3}/src/json_stream/httpx/tests/test_httpx.py +0 -0
- {json-stream-2.3.2 → json_stream-2.3.3}/src/json_stream/iterators.py +0 -0
- {json-stream-2.3.2 → json_stream-2.3.3}/src/json_stream/loader.py +0 -0
- {json-stream-2.3.2 → json_stream-2.3.3}/src/json_stream/requests/__init__.py +0 -0
- {json-stream-2.3.2 → json_stream-2.3.3}/src/json_stream/requests/tests/__init__.py +0 -0
- {json-stream-2.3.2 → json_stream-2.3.3}/src/json_stream/requests/tests/test_requests.py +0 -0
- {json-stream-2.3.2 → json_stream-2.3.3}/src/json_stream/select_tokenizer.py +0 -0
- {json-stream-2.3.2 → json_stream-2.3.3}/src/json_stream/tests/__init__.py +0 -0
- {json-stream-2.3.2 → json_stream-2.3.3}/src/json_stream/tests/test_iterators.py +0 -0
- {json-stream-2.3.2 → json_stream-2.3.3}/src/json_stream/tests/test_loader.py +0 -0
- {json-stream-2.3.2 → json_stream-2.3.3}/src/json_stream/tests/test_tokenizer.py +0 -0
- {json-stream-2.3.2 → json_stream-2.3.3}/src/json_stream/tests/test_util.py +0 -0
- {json-stream-2.3.2 → json_stream-2.3.3}/src/json_stream/tests/test_visitor.py +0 -0
- {json-stream-2.3.2 → json_stream-2.3.3}/src/json_stream/tokenizer.py +0 -0
- {json-stream-2.3.2 → json_stream-2.3.3}/src/json_stream/util.py +0 -0
- {json-stream-2.3.2 → json_stream-2.3.3}/src/json_stream/visitor.py +0 -0
- {json-stream-2.3.2 → json_stream-2.3.3}/src/json_stream.egg-info/dependency_links.txt +0 -0
- {json-stream-2.3.2 → json_stream-2.3.3}/src/json_stream.egg-info/requires.txt +0 -0
- {json-stream-2.3.2 → json_stream-2.3.3}/src/json_stream.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
2
|
Name: json-stream
|
|
3
|
-
Version: 2.3.
|
|
3
|
+
Version: 2.3.3
|
|
4
4
|
Summary: Streaming JSON encoder and decoder
|
|
5
5
|
Author-email: Jamie Cockburn <jamie_cockburn@hotmail.co.uk>
|
|
6
6
|
License: Copyright (c) 2020 Jamie Cockburn
|
|
@@ -33,16 +33,20 @@ Classifier: Intended Audience :: Developers
|
|
|
33
33
|
Classifier: Topic :: Software Development :: Libraries
|
|
34
34
|
Classifier: License :: OSI Approved :: MIT License
|
|
35
35
|
Classifier: Programming Language :: Python :: 3 :: Only
|
|
36
|
-
Classifier: Programming Language :: Python :: 3.7
|
|
37
36
|
Classifier: Programming Language :: Python :: 3.8
|
|
38
37
|
Classifier: Programming Language :: Python :: 3.9
|
|
39
38
|
Classifier: Programming Language :: Python :: 3.10
|
|
40
39
|
Classifier: Programming Language :: Python :: 3.11
|
|
40
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
41
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
41
42
|
Requires-Python: <4,>=3.5
|
|
42
43
|
Description-Content-Type: text/markdown
|
|
44
|
+
License-File: LICENSE.txt
|
|
45
|
+
Requires-Dist: json-stream-rs-tokenizer>=0.4.17
|
|
43
46
|
Provides-Extra: requests
|
|
47
|
+
Requires-Dist: requests; extra == "requests"
|
|
44
48
|
Provides-Extra: httpx
|
|
45
|
-
|
|
49
|
+
Requires-Dist: httpx; extra == "httpx"
|
|
46
50
|
|
|
47
51
|
# json-stream
|
|
48
52
|
|
|
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
|
|
|
5
5
|
|
|
6
6
|
[project]
|
|
7
7
|
name = "json-stream"
|
|
8
|
-
version = "2.3.
|
|
8
|
+
version = "2.3.3"
|
|
9
9
|
authors = [
|
|
10
10
|
{name = "Jamie Cockburn", email="jamie_cockburn@hotmail.co.uk"},
|
|
11
11
|
]
|
|
@@ -18,11 +18,12 @@ classifiers = [
|
|
|
18
18
|
"Topic :: Software Development :: Libraries",
|
|
19
19
|
"License :: OSI Approved :: MIT License",
|
|
20
20
|
"Programming Language :: Python :: 3 :: Only",
|
|
21
|
-
"Programming Language :: Python :: 3.7",
|
|
22
21
|
"Programming Language :: Python :: 3.8",
|
|
23
22
|
"Programming Language :: Python :: 3.9",
|
|
24
23
|
"Programming Language :: Python :: 3.10",
|
|
25
24
|
"Programming Language :: Python :: 3.11",
|
|
25
|
+
"Programming Language :: Python :: 3.12",
|
|
26
|
+
"Programming Language :: Python :: 3.13",
|
|
26
27
|
]
|
|
27
28
|
requires-python = ">=3.5,<4"
|
|
28
29
|
dependencies = ["json-stream-rs-tokenizer >= 0.4.17"]
|
|
@@ -3,7 +3,7 @@ import copy
|
|
|
3
3
|
from abc import ABC
|
|
4
4
|
from collections import OrderedDict
|
|
5
5
|
from itertools import chain
|
|
6
|
-
from typing import Optional, Iterator, Any
|
|
6
|
+
from typing import Optional, Iterator, Any, Mapping, Sequence
|
|
7
7
|
|
|
8
8
|
from json_stream.tokenizer import TokenType
|
|
9
9
|
|
|
@@ -159,6 +159,7 @@ class StreamingJSONList(StreamingJSONBase, ABC):
|
|
|
159
159
|
return self._iter_items()
|
|
160
160
|
|
|
161
161
|
|
|
162
|
+
@Sequence.register
|
|
162
163
|
class PersistentStreamingJSONList(PersistentStreamingJSONBase, StreamingJSONList):
|
|
163
164
|
def _init_persistent_data(self):
|
|
164
165
|
return []
|
|
@@ -184,6 +185,7 @@ class PersistentStreamingJSONList(PersistentStreamingJSONBase, StreamingJSONList
|
|
|
184
185
|
return self._find_item(k)
|
|
185
186
|
|
|
186
187
|
|
|
188
|
+
@Sequence.register
|
|
187
189
|
class TransientStreamingJSONList(TransientStreamingJSONBase, StreamingJSONList):
|
|
188
190
|
def __init__(self, token_stream):
|
|
189
191
|
super().__init__(token_stream)
|
|
@@ -250,6 +252,7 @@ class StreamingJSONObject(StreamingJSONBase, ABC):
|
|
|
250
252
|
return default
|
|
251
253
|
|
|
252
254
|
|
|
255
|
+
@Mapping.register
|
|
253
256
|
class PersistentStreamingJSONObject(PersistentStreamingJSONBase, StreamingJSONObject):
|
|
254
257
|
def _init_persistent_data(self):
|
|
255
258
|
return OrderedDict()
|
|
@@ -276,6 +279,7 @@ class PersistentStreamingJSONObject(PersistentStreamingJSONBase, StreamingJSONOb
|
|
|
276
279
|
return self._find_item(k)
|
|
277
280
|
|
|
278
281
|
|
|
282
|
+
@Mapping.register
|
|
279
283
|
class TransientStreamingJSONObject(TransientStreamingJSONBase, StreamingJSONObject):
|
|
280
284
|
def _find_item(self, k):
|
|
281
285
|
was_started = self._started
|
|
@@ -1,20 +1,11 @@
|
|
|
1
1
|
from unittest import TestCase
|
|
2
2
|
|
|
3
|
-
from json_stream_rs_tokenizer import rust_tokenizer_or_raise
|
|
4
|
-
|
|
5
3
|
import json_stream
|
|
6
4
|
from json_stream import to_standard_types
|
|
7
|
-
from json_stream.tokenizer import tokenize
|
|
8
5
|
|
|
9
6
|
|
|
10
7
|
class TestBuffering(TestCase):
|
|
11
|
-
def
|
|
12
|
-
self._test_buffering(tokenizer=rust_tokenizer_or_raise())
|
|
13
|
-
|
|
14
|
-
def test_buffering_python_tokenizer(self):
|
|
15
|
-
self._test_buffering(tokenizer=tokenize)
|
|
16
|
-
|
|
17
|
-
def _test_buffering(self, tokenizer):
|
|
8
|
+
def test_no_buffering(self):
|
|
18
9
|
happenings = []
|
|
19
10
|
|
|
20
11
|
def data_in_chunks(data, chunk_size=15):
|
|
@@ -24,7 +15,7 @@ class TestBuffering(TestCase):
|
|
|
24
15
|
yield part
|
|
25
16
|
|
|
26
17
|
json_string = b'{"tasks":[{"id":1,"title":"task1"},{"id":2,"title":"task2"},{"id":3,"title":"task3"}]}'
|
|
27
|
-
stream = json_stream.load(data_in_chunks(json_string)
|
|
18
|
+
stream = json_stream.load(data_in_chunks(json_string))
|
|
28
19
|
|
|
29
20
|
for task in stream["tasks"]:
|
|
30
21
|
happenings.append(('item', to_standard_types(task)))
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from typing import Mapping, Sequence
|
|
2
|
+
|
|
3
|
+
from json_stream.select_tokenizer import default_tokenizer
|
|
4
|
+
from json_stream.tests import JSONLoadTestCase
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class TestCollectionABCs(JSONLoadTestCase):
|
|
8
|
+
|
|
9
|
+
def test_isinstance_sequence(self):
|
|
10
|
+
for persistent in (True, False):
|
|
11
|
+
with self.subTest(persistent=persistent):
|
|
12
|
+
self.assertIsInstance(self._to_data([], persistent, False, default_tokenizer), Sequence)
|
|
13
|
+
|
|
14
|
+
def test_isinstance_mapping(self):
|
|
15
|
+
for persistent in (True, False):
|
|
16
|
+
with self.subTest(persistent=persistent):
|
|
17
|
+
self.assertIsInstance(self._to_data({}, persistent, False, default_tokenizer), Mapping)
|
|
@@ -4,24 +4,12 @@ from unittest import skipUnless
|
|
|
4
4
|
import json_stream_rs_tokenizer
|
|
5
5
|
|
|
6
6
|
from json_stream import load
|
|
7
|
-
from json_stream.tokenizer import tokenize
|
|
8
7
|
|
|
9
8
|
from json_stream.select_tokenizer import default_tokenizer
|
|
10
9
|
|
|
11
10
|
from json_stream.tests import JSONLoadTestCase
|
|
12
11
|
|
|
13
12
|
|
|
14
|
-
class TestPythonTokenizer(JSONLoadTestCase):
|
|
15
|
-
def test_load_object(self):
|
|
16
|
-
obj = {"a": 1, "b": None, "c": True}
|
|
17
|
-
self._test_object(obj, persistent=False, tokenizer=tokenize)
|
|
18
|
-
|
|
19
|
-
def test_load_object_binary(self):
|
|
20
|
-
self.assertIs(default_tokenizer, json_stream_rs_tokenizer.RustTokenizer)
|
|
21
|
-
obj = {"a": 1, "b": None, "c": True}
|
|
22
|
-
self._test_object(obj, persistent=False, binary=True, tokenizer=tokenize)
|
|
23
|
-
|
|
24
|
-
|
|
25
13
|
@skipUnless(hasattr(json_stream_rs_tokenizer, 'RustTokenizer'), 'rust tokenizer not available')
|
|
26
14
|
class TestRSTokenizer(JSONLoadTestCase):
|
|
27
15
|
def test_load_object(self):
|
|
@@ -5,19 +5,19 @@ from unittest import TestCase
|
|
|
5
5
|
from json_stream.writer import streamable_dict, streamable_list
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
class
|
|
8
|
+
class BaseTestWriter:
|
|
9
|
+
def dump(self, o):
|
|
10
|
+
raise NotImplementedError()
|
|
11
|
+
|
|
9
12
|
def test_writer_wrapper(self):
|
|
10
13
|
def dict_content(n):
|
|
11
14
|
yield "a list", streamable_list(range(4))
|
|
12
15
|
|
|
13
16
|
o = streamable_dict(dict_content(5))
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
json.dump(o, buffer)
|
|
17
|
-
self.assertEqual('{"a list": [0, 1, 2, 3]}', buffer.getvalue())
|
|
17
|
+
result = self.dump(o)
|
|
18
|
+
self.assertEqual('{"a list": [0, 1, 2, 3]}', result)
|
|
18
19
|
|
|
19
20
|
def test_writer_decorator(self):
|
|
20
|
-
|
|
21
21
|
@streamable_list
|
|
22
22
|
def list_content(n):
|
|
23
23
|
return range(n)
|
|
@@ -28,19 +28,27 @@ class TestWriter(TestCase):
|
|
|
28
28
|
|
|
29
29
|
o = dict_content(5)
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
self.assertEqual('{"a list": [0, 1, 2, 3, 4]}', buffer.getvalue())
|
|
31
|
+
result = self.dump(o)
|
|
32
|
+
self.assertEqual('{"a list": [0, 1, 2, 3, 4]}', result)
|
|
34
33
|
|
|
35
34
|
def test_writer_empty(self):
|
|
36
|
-
|
|
37
35
|
@streamable_list
|
|
38
36
|
def empty_list():
|
|
39
37
|
for i in range(0): # never yields
|
|
40
38
|
yield i
|
|
41
39
|
|
|
42
40
|
o = empty_list()
|
|
41
|
+
result = self.dump(o)
|
|
42
|
+
self.assertEqual('[]', result)
|
|
43
|
+
|
|
43
44
|
|
|
45
|
+
class TestWriterDump(BaseTestWriter, TestCase):
|
|
46
|
+
def dump(self, o):
|
|
44
47
|
buffer = StringIO()
|
|
45
48
|
json.dump(o, buffer)
|
|
46
|
-
|
|
49
|
+
return buffer.getvalue()
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
class TestWriterDumps(BaseTestWriter, TestCase):
|
|
53
|
+
def dump(self, o):
|
|
54
|
+
return json.dumps(o)
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import typing
|
|
1
2
|
from collections import deque
|
|
2
3
|
from functools import wraps
|
|
3
4
|
|
|
4
5
|
|
|
5
6
|
class Streamable:
|
|
6
|
-
def __init__(self, iterable):
|
|
7
|
-
super().__init__()
|
|
7
|
+
def __init__(self, iterable, *args, **kwargs):
|
|
8
|
+
super().__init__(*args, **kwargs)
|
|
8
9
|
self._it = iter(iterable)
|
|
9
10
|
self._cache = deque()
|
|
10
11
|
|
|
@@ -48,6 +49,9 @@ class StreamableDict(Streamable, dict):
|
|
|
48
49
|
for lists, except items are provided by passed in
|
|
49
50
|
generator. Generator must produce pairs of key/value
|
|
50
51
|
"""
|
|
52
|
+
def __init__(self, iterable):
|
|
53
|
+
super().__init__(iterable, {'__error__': 'json-stream error'})
|
|
54
|
+
|
|
51
55
|
def items(self):
|
|
52
56
|
return self
|
|
53
57
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
2
|
Name: json-stream
|
|
3
|
-
Version: 2.3.
|
|
3
|
+
Version: 2.3.3
|
|
4
4
|
Summary: Streaming JSON encoder and decoder
|
|
5
5
|
Author-email: Jamie Cockburn <jamie_cockburn@hotmail.co.uk>
|
|
6
6
|
License: Copyright (c) 2020 Jamie Cockburn
|
|
@@ -33,16 +33,20 @@ Classifier: Intended Audience :: Developers
|
|
|
33
33
|
Classifier: Topic :: Software Development :: Libraries
|
|
34
34
|
Classifier: License :: OSI Approved :: MIT License
|
|
35
35
|
Classifier: Programming Language :: Python :: 3 :: Only
|
|
36
|
-
Classifier: Programming Language :: Python :: 3.7
|
|
37
36
|
Classifier: Programming Language :: Python :: 3.8
|
|
38
37
|
Classifier: Programming Language :: Python :: 3.9
|
|
39
38
|
Classifier: Programming Language :: Python :: 3.10
|
|
40
39
|
Classifier: Programming Language :: Python :: 3.11
|
|
40
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
41
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
41
42
|
Requires-Python: <4,>=3.5
|
|
42
43
|
Description-Content-Type: text/markdown
|
|
44
|
+
License-File: LICENSE.txt
|
|
45
|
+
Requires-Dist: json-stream-rs-tokenizer>=0.4.17
|
|
43
46
|
Provides-Extra: requests
|
|
47
|
+
Requires-Dist: requests; extra == "requests"
|
|
44
48
|
Provides-Extra: httpx
|
|
45
|
-
|
|
49
|
+
Requires-Dist: httpx; extra == "httpx"
|
|
46
50
|
|
|
47
51
|
# json-stream
|
|
48
52
|
|
|
@@ -27,6 +27,7 @@ src/json_stream/requests/tests/__init__.py
|
|
|
27
27
|
src/json_stream/requests/tests/test_requests.py
|
|
28
28
|
src/json_stream/tests/__init__.py
|
|
29
29
|
src/json_stream/tests/test_buffering.py
|
|
30
|
+
src/json_stream/tests/test_collection_abcs.py
|
|
30
31
|
src/json_stream/tests/test_iterators.py
|
|
31
32
|
src/json_stream/tests/test_loader.py
|
|
32
33
|
src/json_stream/tests/test_tokenizer.py
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|