pycborstream 0.0.2__tar.gz → 0.0.4__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.
- pycborstream-0.0.4/PKG-INFO +65 -0
- pycborstream-0.0.4/README.md +48 -0
- pycborstream-0.0.4/pycborstream.egg-info/PKG-INFO +65 -0
- {pycborstream-0.0.2 → pycborstream-0.0.4}/pycborstream.egg-info/SOURCES.txt +3 -1
- pycborstream-0.0.4/pycborstream.egg-info/requires.txt +1 -0
- {pycborstream-0.0.2 → pycborstream-0.0.4}/pyproject.toml +4 -2
- {pycborstream-0.0.2 → pycborstream-0.0.4}/setup.py +1 -1
- pycborstream-0.0.4/tests/test_snippet_code.py +32 -0
- pycborstream-0.0.2/PKG-INFO +0 -19
- pycborstream-0.0.2/README.md +0 -3
- pycborstream-0.0.2/pycborstream.egg-info/PKG-INFO +0 -19
- {pycborstream-0.0.2 → pycborstream-0.0.4}/LICENSE +0 -0
- {pycborstream-0.0.2 → pycborstream-0.0.4}/pycborstream/__init__.py +0 -0
- {pycborstream-0.0.2 → pycborstream-0.0.4}/pycborstream/cborstreamdec.py +0 -0
- {pycborstream-0.0.2 → pycborstream-0.0.4}/pycborstream/cborstreamenc.py +0 -0
- {pycborstream-0.0.2 → pycborstream-0.0.4}/pycborstream.egg-info/dependency_links.txt +0 -0
- {pycborstream-0.0.2 → pycborstream-0.0.4}/pycborstream.egg-info/top_level.txt +0 -0
- {pycborstream-0.0.2 → pycborstream-0.0.4}/setup.cfg +0 -0
- {pycborstream-0.0.2 → pycborstream-0.0.4}/tests/__init__.py +0 -0
- {pycborstream-0.0.2 → pycborstream-0.0.4}/tests/generate_cbor.py +0 -0
- {pycborstream-0.0.2 → pycborstream-0.0.4}/tests/test_cborstreamdec.py +0 -0
- {pycborstream-0.0.2 → pycborstream-0.0.4}/tests/test_cborstreamenc.py +0 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pycborstream
|
|
3
|
+
Version: 0.0.4
|
|
4
|
+
Summary: Stream API using cbor2 to read and write CBOR data.
|
|
5
|
+
Author: Olivier Langella
|
|
6
|
+
Author-email: Olivier Langella <olivier.langella@cnrs.fr>
|
|
7
|
+
License-Expression: GPL-3.0-or-later
|
|
8
|
+
Project-URL: source, https://codeberg.org/PAPPSO/pycborstream
|
|
9
|
+
Project-URL: tracker, https://codeberg.org/PAPPSO/pycborstream/issues
|
|
10
|
+
Keywords: stream,CBOR
|
|
11
|
+
Requires-Python: >=3.11
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Requires-Dist: cbor2<6.0.0,>=5.9.0
|
|
15
|
+
Dynamic: author
|
|
16
|
+
Dynamic: license-file
|
|
17
|
+
|
|
18
|
+
# pycborstream
|
|
19
|
+
|
|
20
|
+
Simple python API to handle CBOR files as streams. It provides lazy methods to read and write huge CBOR data files saving memory: data can be treated on the fly without having to load the entire structure.
|
|
21
|
+
|
|
22
|
+
Pycborstream mimics the C++ [QCborStreamReader Class](https://doc.qt.io/qt-6/qcborstreamreader.html) and [QCborStreamWriter Class](https://doc.qt.io/qt-6/qcborstreamwriter.html) API to read and write CBOR data. It uses [cbor2](https://github.com/agronholm/cbor2) under the hood, and combines it to also read/write directly python dictionnaries and arrays.
|
|
23
|
+
|
|
24
|
+
## Simple usage: write a CBOR data file
|
|
25
|
+
|
|
26
|
+
```python
|
|
27
|
+
from io import BytesIO
|
|
28
|
+
|
|
29
|
+
from pycborstream import CborStreamEnc
|
|
30
|
+
|
|
31
|
+
cbor_out = "data.cbor"
|
|
32
|
+
with open(cbor_out, "wb") as fp:
|
|
33
|
+
cbor_encoder = CborStreamEnc(fp)
|
|
34
|
+
cbor_encoder.startMap(2) # start a map containing 2 key/value pairs
|
|
35
|
+
cbor_encoder.append("first_key")
|
|
36
|
+
cbor_encoder.startArray(None) # start an array of undefined length
|
|
37
|
+
cbor_encoder.append(5)
|
|
38
|
+
cbor_encoder.append(6)
|
|
39
|
+
cbor_encoder.append(7)
|
|
40
|
+
cbor_encoder.endArray()
|
|
41
|
+
cbor_encoder.append("second_key")
|
|
42
|
+
cbor_encoder.append("could be a new map or whatever")
|
|
43
|
+
cbor_encoder.endMap()
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Simple usage: read this CBOR data file
|
|
47
|
+
|
|
48
|
+
```python
|
|
49
|
+
from io import BytesIO
|
|
50
|
+
|
|
51
|
+
from pycborstream import CborStreamDec
|
|
52
|
+
|
|
53
|
+
with open(cbor_out, "rb") as fp:
|
|
54
|
+
cbor_decoder = CborStreamDec(fp)
|
|
55
|
+
cbor_decoder.enter_container() # enters the map (containing 2 keys)
|
|
56
|
+
assert cbor_decoder.value() == "first_key"
|
|
57
|
+
assert cbor_decoder.is_array() # next value is an array
|
|
58
|
+
assert cbor_decoder.length == None # length of array is not known
|
|
59
|
+
cbor_decoder.enter_container()
|
|
60
|
+
while cbor_decoder.has_next(): # loop on elements in the array
|
|
61
|
+
print(cbor_decoder.value())
|
|
62
|
+
cbor_decoder.leave_container() # we have to leave container to proceed
|
|
63
|
+
assert cbor_decoder.value() == "second_key"
|
|
64
|
+
assert cbor_decoder.value() == "could be a new map or whatever"
|
|
65
|
+
```
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# pycborstream
|
|
2
|
+
|
|
3
|
+
Simple python API to handle CBOR files as streams. It provides lazy methods to read and write huge CBOR data files saving memory: data can be treated on the fly without having to load the entire structure.
|
|
4
|
+
|
|
5
|
+
Pycborstream mimics the C++ [QCborStreamReader Class](https://doc.qt.io/qt-6/qcborstreamreader.html) and [QCborStreamWriter Class](https://doc.qt.io/qt-6/qcborstreamwriter.html) API to read and write CBOR data. It uses [cbor2](https://github.com/agronholm/cbor2) under the hood, and combines it to also read/write directly python dictionnaries and arrays.
|
|
6
|
+
|
|
7
|
+
## Simple usage: write a CBOR data file
|
|
8
|
+
|
|
9
|
+
```python
|
|
10
|
+
from io import BytesIO
|
|
11
|
+
|
|
12
|
+
from pycborstream import CborStreamEnc
|
|
13
|
+
|
|
14
|
+
cbor_out = "data.cbor"
|
|
15
|
+
with open(cbor_out, "wb") as fp:
|
|
16
|
+
cbor_encoder = CborStreamEnc(fp)
|
|
17
|
+
cbor_encoder.startMap(2) # start a map containing 2 key/value pairs
|
|
18
|
+
cbor_encoder.append("first_key")
|
|
19
|
+
cbor_encoder.startArray(None) # start an array of undefined length
|
|
20
|
+
cbor_encoder.append(5)
|
|
21
|
+
cbor_encoder.append(6)
|
|
22
|
+
cbor_encoder.append(7)
|
|
23
|
+
cbor_encoder.endArray()
|
|
24
|
+
cbor_encoder.append("second_key")
|
|
25
|
+
cbor_encoder.append("could be a new map or whatever")
|
|
26
|
+
cbor_encoder.endMap()
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Simple usage: read this CBOR data file
|
|
30
|
+
|
|
31
|
+
```python
|
|
32
|
+
from io import BytesIO
|
|
33
|
+
|
|
34
|
+
from pycborstream import CborStreamDec
|
|
35
|
+
|
|
36
|
+
with open(cbor_out, "rb") as fp:
|
|
37
|
+
cbor_decoder = CborStreamDec(fp)
|
|
38
|
+
cbor_decoder.enter_container() # enters the map (containing 2 keys)
|
|
39
|
+
assert cbor_decoder.value() == "first_key"
|
|
40
|
+
assert cbor_decoder.is_array() # next value is an array
|
|
41
|
+
assert cbor_decoder.length == None # length of array is not known
|
|
42
|
+
cbor_decoder.enter_container()
|
|
43
|
+
while cbor_decoder.has_next(): # loop on elements in the array
|
|
44
|
+
print(cbor_decoder.value())
|
|
45
|
+
cbor_decoder.leave_container() # we have to leave container to proceed
|
|
46
|
+
assert cbor_decoder.value() == "second_key"
|
|
47
|
+
assert cbor_decoder.value() == "could be a new map or whatever"
|
|
48
|
+
```
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pycborstream
|
|
3
|
+
Version: 0.0.4
|
|
4
|
+
Summary: Stream API using cbor2 to read and write CBOR data.
|
|
5
|
+
Author: Olivier Langella
|
|
6
|
+
Author-email: Olivier Langella <olivier.langella@cnrs.fr>
|
|
7
|
+
License-Expression: GPL-3.0-or-later
|
|
8
|
+
Project-URL: source, https://codeberg.org/PAPPSO/pycborstream
|
|
9
|
+
Project-URL: tracker, https://codeberg.org/PAPPSO/pycborstream/issues
|
|
10
|
+
Keywords: stream,CBOR
|
|
11
|
+
Requires-Python: >=3.11
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Requires-Dist: cbor2<6.0.0,>=5.9.0
|
|
15
|
+
Dynamic: author
|
|
16
|
+
Dynamic: license-file
|
|
17
|
+
|
|
18
|
+
# pycborstream
|
|
19
|
+
|
|
20
|
+
Simple python API to handle CBOR files as streams. It provides lazy methods to read and write huge CBOR data files saving memory: data can be treated on the fly without having to load the entire structure.
|
|
21
|
+
|
|
22
|
+
Pycborstream mimics the C++ [QCborStreamReader Class](https://doc.qt.io/qt-6/qcborstreamreader.html) and [QCborStreamWriter Class](https://doc.qt.io/qt-6/qcborstreamwriter.html) API to read and write CBOR data. It uses [cbor2](https://github.com/agronholm/cbor2) under the hood, and combines it to also read/write directly python dictionnaries and arrays.
|
|
23
|
+
|
|
24
|
+
## Simple usage: write a CBOR data file
|
|
25
|
+
|
|
26
|
+
```python
|
|
27
|
+
from io import BytesIO
|
|
28
|
+
|
|
29
|
+
from pycborstream import CborStreamEnc
|
|
30
|
+
|
|
31
|
+
cbor_out = "data.cbor"
|
|
32
|
+
with open(cbor_out, "wb") as fp:
|
|
33
|
+
cbor_encoder = CborStreamEnc(fp)
|
|
34
|
+
cbor_encoder.startMap(2) # start a map containing 2 key/value pairs
|
|
35
|
+
cbor_encoder.append("first_key")
|
|
36
|
+
cbor_encoder.startArray(None) # start an array of undefined length
|
|
37
|
+
cbor_encoder.append(5)
|
|
38
|
+
cbor_encoder.append(6)
|
|
39
|
+
cbor_encoder.append(7)
|
|
40
|
+
cbor_encoder.endArray()
|
|
41
|
+
cbor_encoder.append("second_key")
|
|
42
|
+
cbor_encoder.append("could be a new map or whatever")
|
|
43
|
+
cbor_encoder.endMap()
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Simple usage: read this CBOR data file
|
|
47
|
+
|
|
48
|
+
```python
|
|
49
|
+
from io import BytesIO
|
|
50
|
+
|
|
51
|
+
from pycborstream import CborStreamDec
|
|
52
|
+
|
|
53
|
+
with open(cbor_out, "rb") as fp:
|
|
54
|
+
cbor_decoder = CborStreamDec(fp)
|
|
55
|
+
cbor_decoder.enter_container() # enters the map (containing 2 keys)
|
|
56
|
+
assert cbor_decoder.value() == "first_key"
|
|
57
|
+
assert cbor_decoder.is_array() # next value is an array
|
|
58
|
+
assert cbor_decoder.length == None # length of array is not known
|
|
59
|
+
cbor_decoder.enter_container()
|
|
60
|
+
while cbor_decoder.has_next(): # loop on elements in the array
|
|
61
|
+
print(cbor_decoder.value())
|
|
62
|
+
cbor_decoder.leave_container() # we have to leave container to proceed
|
|
63
|
+
assert cbor_decoder.value() == "second_key"
|
|
64
|
+
assert cbor_decoder.value() == "could be a new map or whatever"
|
|
65
|
+
```
|
|
@@ -8,8 +8,10 @@ pycborstream/cborstreamenc.py
|
|
|
8
8
|
pycborstream.egg-info/PKG-INFO
|
|
9
9
|
pycborstream.egg-info/SOURCES.txt
|
|
10
10
|
pycborstream.egg-info/dependency_links.txt
|
|
11
|
+
pycborstream.egg-info/requires.txt
|
|
11
12
|
pycborstream.egg-info/top_level.txt
|
|
12
13
|
tests/__init__.py
|
|
13
14
|
tests/generate_cbor.py
|
|
14
15
|
tests/test_cborstreamdec.py
|
|
15
|
-
tests/test_cborstreamenc.py
|
|
16
|
+
tests/test_cborstreamenc.py
|
|
17
|
+
tests/test_snippet_code.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
cbor2<6.0.0,>=5.9.0
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
authors = [{name = "Olivier Langella", email = "olivier.langella@cnrs.fr"}]
|
|
3
3
|
description = "Stream API using cbor2 to read and write CBOR data."
|
|
4
|
-
dependencies = []
|
|
5
4
|
name = "pycborstream"
|
|
6
5
|
requires-python = ">= 3.11"
|
|
7
|
-
version = "0.0.
|
|
6
|
+
version = "0.0.4"
|
|
8
7
|
readme = "README.md"
|
|
9
8
|
license = "GPL-3.0-or-later"
|
|
9
|
+
dependencies = [
|
|
10
|
+
"cbor2>=5.9.0,<6.0.0",
|
|
11
|
+
]
|
|
10
12
|
|
|
11
13
|
keywords = [
|
|
12
14
|
"stream",
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
from io import BytesIO
|
|
2
|
+
|
|
3
|
+
from pycborstream import CborStreamDec, CborStreamEnc
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def test_snippet_code():
|
|
7
|
+
cbor_out = "data.cbor"
|
|
8
|
+
with open(cbor_out, "wb") as fp:
|
|
9
|
+
cbor_encoder = CborStreamEnc(fp)
|
|
10
|
+
cbor_encoder.startMap(2) # start a map containing 2 key/value pairs
|
|
11
|
+
cbor_encoder.append("first_key")
|
|
12
|
+
cbor_encoder.startArray(None) # start an array of undefined length
|
|
13
|
+
cbor_encoder.append(5)
|
|
14
|
+
cbor_encoder.append(6)
|
|
15
|
+
cbor_encoder.append(7)
|
|
16
|
+
cbor_encoder.endArray()
|
|
17
|
+
cbor_encoder.append("second_key")
|
|
18
|
+
cbor_encoder.append("could be a new map or whatever")
|
|
19
|
+
cbor_encoder.endMap()
|
|
20
|
+
|
|
21
|
+
with open(cbor_out, "rb") as fp:
|
|
22
|
+
cbor_decoder = CborStreamDec(fp)
|
|
23
|
+
cbor_decoder.enter_container() # enters the map (containing 2 keys)
|
|
24
|
+
assert cbor_decoder.value() == "first_key"
|
|
25
|
+
assert cbor_decoder.is_array() # next value is an array
|
|
26
|
+
assert cbor_decoder.length == None # length of array is not known
|
|
27
|
+
cbor_decoder.enter_container()
|
|
28
|
+
while cbor_decoder.has_next(): # loop on elements in the array
|
|
29
|
+
print(cbor_decoder.value())
|
|
30
|
+
cbor_decoder.leave_container() # we have to leave container to proceed
|
|
31
|
+
assert cbor_decoder.value() == "second_key"
|
|
32
|
+
assert cbor_decoder.value() == "could be a new map or whatever"
|
pycborstream-0.0.2/PKG-INFO
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: pycborstream
|
|
3
|
-
Version: 0.0.2
|
|
4
|
-
Summary: Stream API using cbor2 to read and write CBOR data.
|
|
5
|
-
Author: Olivier Langella
|
|
6
|
-
Author-email: Olivier Langella <olivier.langella@cnrs.fr>
|
|
7
|
-
License-Expression: GPL-3.0-or-later
|
|
8
|
-
Project-URL: source, https://codeberg.org/PAPPSO/pycborstream
|
|
9
|
-
Project-URL: tracker, https://codeberg.org/PAPPSO/pycborstream/issues
|
|
10
|
-
Keywords: stream,CBOR
|
|
11
|
-
Requires-Python: >=3.11
|
|
12
|
-
Description-Content-Type: text/markdown
|
|
13
|
-
License-File: LICENSE
|
|
14
|
-
Dynamic: author
|
|
15
|
-
Dynamic: license-file
|
|
16
|
-
|
|
17
|
-
# pycborstream
|
|
18
|
-
|
|
19
|
-
Simple python API to handle CBOR files as streams. It provides lazy methods to read and write huge CBOR data files saving memory: data can be treated on the fly without having to load the entire structure.
|
pycborstream-0.0.2/README.md
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: pycborstream
|
|
3
|
-
Version: 0.0.2
|
|
4
|
-
Summary: Stream API using cbor2 to read and write CBOR data.
|
|
5
|
-
Author: Olivier Langella
|
|
6
|
-
Author-email: Olivier Langella <olivier.langella@cnrs.fr>
|
|
7
|
-
License-Expression: GPL-3.0-or-later
|
|
8
|
-
Project-URL: source, https://codeberg.org/PAPPSO/pycborstream
|
|
9
|
-
Project-URL: tracker, https://codeberg.org/PAPPSO/pycborstream/issues
|
|
10
|
-
Keywords: stream,CBOR
|
|
11
|
-
Requires-Python: >=3.11
|
|
12
|
-
Description-Content-Type: text/markdown
|
|
13
|
-
License-File: LICENSE
|
|
14
|
-
Dynamic: author
|
|
15
|
-
Dynamic: license-file
|
|
16
|
-
|
|
17
|
-
# pycborstream
|
|
18
|
-
|
|
19
|
-
Simple python API to handle CBOR files as streams. It provides lazy methods to read and write huge CBOR data files saving memory: data can be treated on the fly without having to load the entire structure.
|
|
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
|