Skip to main content

Bencodex reader/writer for Python

Project description

Build Status

This package implements Bencodex serialization format which extends Bencoding.

Usage

This package’s API follows the tradition of Python’s pickle and json modules:

  • bencodex.dump(obj: bencodex.BValue, fileobj: typing.BinaryIO) -> None

  • bencodex.dumps(obj: bencodex.BValue) -> bytes

  • bencodex.load(fileobj: typing.BinaryIO) -> bencodex.BValue

  • bencodex.loads(encoded: bytes) -> bencodex.BValue

Examples

>>> from bencodex import dumps, loads
>>> dumps({'name': 'Jane Doe', 'age': 30, 'nationality': ['BR', 'US']})
b'du3:agei30eu4:nameu8:Jane Doeu11:nationalitylu2:BRu2:USee'
>>> loads(_)
{'age': 30, 'name': 'Jane Doe', 'nationality': ['BR', 'US']}

License

Distributed under GPLv3 or later.

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

bencodex-1.0.1.tar.gz (8.7 kB view hashes)

Uploaded Source

Built Distribution

bencodex-1.0.1-py3-none-any.whl (16.1 kB view hashes)

Uploaded Python 3

Supported by

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