Pyben v0.3.2
Small library for encoding/decoding bencode data. Supports Unicode pathnames as of PyBen 3.0. Pyben Enables fast and easy encoding and decoding of bencoded data.
Prerequisites
Python v3.6+
Installing PyBen
To install PyBen, follow these steps:
Using pip:
pip install pyben
Using git:
git clone https://github.com/alexpdev/pyben.git
Using PyBen
The API is intentionally designed to mimic Python's json and pickle modules.
>>> import os
>>> import pyben
>>> file_path = "path/to/encoded.file"
>>> data = {"item1": ["item2", 3, [4], {5: "item6"}]}
>>> encoded = pyben.dumps(data)
>>> encoded
... b'd5:item1l5:item2i3eli4eedi5e5:item6eee'
>>> decoded = pyben.loads(encoded)
>>> decoded
... {'item1': ['item2', 3, [4], {5: 'item6'}]}
>>> decoded == data
... True
One key difference is that the 'load' and 'dump' methods accept as arguments, string paths or path-like objects as well as an open BytesIO object.
For Example this:
>>> with open(file_path, "wb") as fd:
>>> pyben.dump(decoded, fd)
>>> os.path.exists(file_path)
... True
>>> with open(file_path, "rb") as fd:
>>> decoded_file = pyben.load(fd)
>>> decoded_file == decoded == data
... True
is the same as doing following.
>>> pyben.dump(data, file_path)
>>> os.path.exists(file_path)
... True
>>> decoded_file = pyben.load(file_path)
>>> decoded_file == decoded == data
... True
The full API includes many other functions and classes as well. See docs for more full API.
License
This project uses the following license: Apache 2.0
Metadata
Release files for pyben 0.3.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pyben-0.3.2.tar.gz | 81.1 kB | Details |
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyben-0.3.2-py3.10.egg | Legacy Egg format | - | - | Details |
| pyben-0.3.2-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details |
Total release size: 119.0 kB
Release files / pyben-0.3.2.tar.gz
| Download URL | pyben-0.3.2.tar.gz |
|---|---|
| Size | 81.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
523eeebda9fbd30b523cac27d1eb83896f18599e7efee6a5319b682585f3ef78
|
|
BLAKE2b-256 checksum How to use checksums |
ba415eea56d283da685a2eb4e9529f2245f16a330af22fbadfddea51f8688a1b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.25.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.62.3 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2
|
Release files / pyben-0.3.2-py3.10.egg
| Download URL | pyben-0.3.2-py3.10.egg |
|---|---|
| Size | 22.2 kB |
| Tags | Egg |
|
SHA-256 checksum How to use checksums |
192cc709093b74038e82972d9592c6865acf23ad0f86b92fb9a787a53e0d5494
|
|
BLAKE2b-256 checksum How to use checksums |
bc3fc47622637f8ecaf064d084e0e52cc2763f17d1439732c69433df37606c9f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.25.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.62.3 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2
|
Release files / pyben-0.3.2-py2.py3-none-any.whl
| Download URL | pyben-0.3.2-py2.py3-none-any.whl |
|---|---|
| Size | 15.7 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
b3ed47ccfbaee443e268ac1a4721b8e211f282f45caa21eb0584cb3865789914
|
|
BLAKE2b-256 checksum How to use checksums |
9688a9dee49a0ea8e9abb14c688a0a38dcde1c6670fb5ce0c8ed74ae0057f27b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.25.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.62.3 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2
|