dag-cbor: A Python implementation of the DAG-CBOR codec
This is a fully compliant Python implementation of the DAG-CBOR codec, a subset of the Concise Binary Object Representation (CBOR) supporting the IPLD Data Model and enforcing a unique (strict) encoded representation of items.
Install
You can install the latest release from PyPI as follows:
$ pip install --upgrade dag-cbor
Usage
We suggest you import DAG-CBOR as follows:
>>> import dag_cbor
Below are some basic usage examples, to get you started: for detailed documentation, see https://dag-cbor.readthedocs.io/
Encoding and decoding
>>> dag_cbor.encode({'a': 12, 'b': 'hello!'})
b'\xa2aa\x0cabfhello!'
>>> dag_cbor.decode(b'\xa2aa\x0cabfhello!')
{'a': 12, 'b': 'hello!'}
Random DAG-CBOR data
>>> import pprint # pretty-printing
>>> custom_opts = dict(min_codepoint=0x41, max_codepoint=0x5a, include_cid=False)
>>> with dag_cbor.random.options(**custom_opts):
... for d in dag_cbor.random.rand_dict(3):
... pprint.pp(d)
...
{'BIQPMZ': b'\x85\x1f\x07/\xcc\x00\xfc\xaa',
'EJEYDTZI': {},
'PLSG': {'G': 'JFG',
'HZE': -61.278,
'JWDRKRGZ': b'-',
'OCCKQPDJ': True,
'SJOCTZMK': False},
'PRDLN': 39.129,
'TUGRP': None,
'WZTEJDXC': -69.933}
{'GHAXI': 39.12,
'PVUWZLC': 4.523,
'TDPSU': 'TVCADUGT',
'ZHGVSNSI': [-57, 9, -78.312]}
{'': 11, 'B': True, 'FWD': {}, 'GXZBVAR': 'BTDWMGI', 'TDICHC': 87}
API
For the full API documentation, see https://dag-cbor.readthedocs.io/
Contributing
Please see CONTRIBUTING.md.
License
Metadata
Release files for dag-cbor 0.3.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| dag-cbor-0.3.3.tar.gz | 54.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| dag_cbor-0.3.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 80.0 kB
Release files / dag-cbor-0.3.3.tar.gz
| Download URL | dag-cbor-0.3.3.tar.gz |
|---|---|
| Size | 54.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d8d1e7c7a022af758932e5343b7a2c9d7afa1cc64860246cae22f90cab1c9d8a
|
|
BLAKE2b-256 checksum How to use checksums |
2818b318561a2cb51bfb80664394c507bad6bf9f77fa9e5e7b56a35cc5fe8772
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.12.0
|
Release files / dag_cbor-0.3.3-py3-none-any.whl
| Download URL | dag_cbor-0.3.3-py3-none-any.whl |
|---|---|
| Size | 25.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e0d1c45427ed1fa21bbd103163d4b250f4ce9066337d6ffb976da1fac3a67454
|
|
BLAKE2b-256 checksum How to use checksums |
148e3fa50f0e4d709610be14b8b8049f5bdd9dbeddf5147286a4c59ba55f8af0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.12.0
|