Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/planetarium/bencodex-python
Bencodex reader/writer for Python
https://github.com/planetarium/bencodex-python
bencode bencodex python python3
Last synced: about 1 month ago
JSON representation
Bencodex reader/writer for Python
- Host: GitHub
- URL: https://github.com/planetarium/bencodex-python
- Owner: planetarium
- License: gpl-3.0
- Created: 2018-10-29T20:29:58.000Z (about 6 years ago)
- Default Branch: main
- Last Pushed: 2022-11-10T03:05:17.000Z (about 2 years ago)
- Last Synced: 2024-10-11T12:37:26.205Z (2 months ago)
- Topics: bencode, bencodex, python, python3
- Language: Python
- Homepage: https://pypi.org/project/bencodex/
- Size: 38.1 KB
- Stars: 5
- Watchers: 10
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.rst
- Changelog: CHANGES.rst
- License: LICENSE
Awesome Lists containing this project
README
Bencodex reader/writer for Python
=================================.. image:: https://img.shields.io/pypi/v/bencodex
:alt: PyPI
:target: https://pypi.org/project/bencodex/.. image:: https://github.com/planetarium/bencodex-python/actions/workflows/build.yaml/badge.svg
:alt: Build Status
:target: https://github.com/planetarium/bencodex-python/actions/workflows/build.yamlThis package implements Bencodex_ serialization format which extends Bencoding_.
.. _Bencodex: https://github.com/planetarium/bencodex
.. _Bencoding: http://www.bittorrent.org/beps/bep_0003.html#bencodingUsage
-----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']}Debug-friendly formatter
------------------------The package also provides a CLI program named ``show-bencodex``, which shows
the given Bencodex data file (or data from the stdin) in the debug-friendly
format:.. code:: console
$ show-bencodex bencodex.dat
$ cat bencodex.dat | show-bencodexLicense
-------Distributed under GPLv3_ or later.
.. _GPLv3: https://www.gnu.org/licenses/gpl-3.0.html