Python implementation of the DAG-CBOR codec.
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file dag-cbor-0.3.2.tar.gz
.
File metadata
- Download URL: dag-cbor-0.3.2.tar.gz
- Upload date:
- Size: 53.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/6.0.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d113050d6f5cb6c1a324c911684c5daa305425702585573269bef3000aa9f106 |
|
MD5 | 704e026d91a1aa1473927fd980300b9a |
|
BLAKE2b-256 | 3e06e51f0a12a1a31fb19ac3158d6811ef5fa02744f2314b46cfb582b23b74d6 |
File details
Details for the file dag_cbor-0.3.2-py3-none-any.whl
.
File metadata
- Download URL: dag_cbor-0.3.2-py3-none-any.whl
- Upload date:
- Size: 25.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/6.0.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c78030379f385b90498711d7613af5bdb4155d5a7623211cea2b20441d5794b4 |
|
MD5 | 70825a45889675d58f48e35032e34470 |
|
BLAKE2b-256 | dda6bdfc9f1a8132c2439e849eee630657b6c15634b284fa553daf9f3d0b6413 |