Skip to main content

dag-cbor: A Python implementation of the DAG-CBOR codec

Python versions PyPI version PyPI status Checked with Mypy Documentation Status Python package status standard-readme compliant

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

MIT © Hashberg Ltd.

Metadata

Release files for makkus.dag-cbor 0.3.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for makkus.dag-cbor 0.3.4
File Size Uploaded
makkus.dag-cbor-0.3.4.tar.gz 52.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for makkus.dag-cbor 0.3.4
File Interpreter ABI Platform
makkus.dag_cbor-0.3.4-py3-none-any.whl Python 3 none any Details

Total release size: 77.6 kB

Release files / makkus.dag-cbor-0.3.4.tar.gz

Download URL makkus.dag-cbor-0.3.4.tar.gz
Size 52.3 kB
Tags Source
SHA-256 checksum
How to use checksums
d3359095accd35f4aa7c33668088a26bba18a1b3c98ac37a146f8603c540a1fb
BLAKE2b-256 checksum
How to use checksums
7a2d683ed8929ddd63a6cccc43321a9f163a9bbe3b3f96b8d047693d4e429307
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/4.0.2 CPython/3.11.6

Release files / makkus.dag_cbor-0.3.4-py3-none-any.whl

Download URL makkus.dag_cbor-0.3.4-py3-none-any.whl
Size 25.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c74ad377a70b7354367692076f982d0e267fb45ba27cd715a09b12fa80344eac
BLAKE2b-256 checksum
How to use checksums
22540901b2b2cc08dbb532c48b9f7a5baf977a0b691009f68c6f47257a0d1363
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/4.0.2 CPython/3.11.6

Release history Release notifications | RSS feed

This release

0.3.4 This release

2 release files

0.3.3

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page