Skip to main content

Multicodec implementation in Python

Project description

py-multicodec

https://img.shields.io/pypi/v/py-multicodec.svg https://img.shields.io/travis/multiformats/py-multicodec.svg?branch=master https://codecov.io/gh/multiformats/py-multicodec/branch/master/graph/badge.svg Documentation Status

Multicodec implementation in Python

multicodec is a self-describing multiformat, it wraps other formats with a tiny bit of self-description.

A multicodec identifier is both a varint and the code identifying the following data, this means that the most significant bit of every multicodec code is reserved to signal the continuation.

You can check the table here for the list of supported codecs by py-multicodec.

Installation

$ pip install py-multicodec

Sample Usage

>>> from multicodec import add_prefix, remove_prefix, get_codec
>>> # adding a prefix to existing data
>>> add_prefix('sha2-256', 'EiC5TSe5k00')
b'\x12EiC5TSe5k00'
>>> # removing prefix from prefixed data
>>> remove_prefix(b'\x12EiC5TSe5k00')
EiC5TSe5k00
>>> # get codec used to prefix the prefixed data
>>> get_codec(b'\x12EiC5TSe5k00')
'sha2-256'

Updating the lookup table

Updating the lookup table is done with a script. The source of truth is the multicodec default table. Update the table with running:

$ curl -X GET https://raw.githubusercontent.com/multiformats/multicodec/master/table.csv | ./tools/update-table.py

History

0.1.3 (2018-10-20)

  • Handle exception when the varint is invalid

0.1.0 (2017-09-03)

  • First release on PyPI.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py-multicodec-0.2.1.tar.gz (22.5 kB view details)

Uploaded Source

Built Distribution

py_multicodec-0.2.1-py2.py3-none-any.whl (8.5 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file py-multicodec-0.2.1.tar.gz.

File metadata

  • Download URL: py-multicodec-0.2.1.tar.gz
  • Upload date:
  • Size: 22.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Python-urllib/3.5

File hashes

Hashes for py-multicodec-0.2.1.tar.gz
Algorithm Hash digest
SHA256 83021ffe8c0e272d19b5b86bc5b39efa67c8e9f4735ce6cafdbc1ace767ec647
MD5 ac5dbadc49ab0e2a792443467c38651f
BLAKE2b-256 7733ff388b34002239c367f6544678667efff079d29aabf7e3c4a3ec392310be

See more details on using hashes here.

File details

Details for the file py_multicodec-0.2.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for py_multicodec-0.2.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 55b6bb53088a63e56c434cb11b29795e8805652bac43d50a8f2a9bcf5ca84e1f
MD5 714726ad3a2d5a0f3d22ac051f258901
BLAKE2b-256 6c963ffb721c2fe100f6613a0d2db3b4b3229c6de52b279fd41aab0e84ea0725

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page