Skip to main content

benparse

benparse is a bencode parser for Python 3. It is capable of reading and creating bencoded files such as torrents

Features

  • Syntax is similar to built-in modules such as json and pickle
  • Has an optional strict mode that will raise an error when it encounters non-fatal errors such as out-of-order dict keys or integers with leading zeros. This ensures that "round-tripping" bencoded data (loading bencoded data and then dumping it back to bencode) will never caused unexpected changes
  • Able to change the character encoding used to encode/decode strings
  • Fully typed

Usage

Complete usage documentation and examples are available here

# Load a bencoded file
with open('linux_distro.torrent', 'rb') as file:
    torrent_dict = benparse.load(file)

# Make changes
torrent_dict[b'announce'] = b'http://mirror.example.org:6969/announce'

# Save a Python object as a bencoded file
with open('linux_distro.torrent', 'wb') as file:
    benparse.dump(torrent_dict, file)

Requirements

Installation

Install from PyPI:

pip3 install benparse

Install from source:

git clone https://gitlab.com/adralioh/benparse.git
pip3 install ./benparse

Tests

Tests are run using the built-in unittest module, and Coverage.py is used to measure code coverage

Run tests without measuring coverage:

python3 -m unittest discover tests

Run tests and measure coverage:

coverage run -m unittest discover tests

View the results:

coverage report

Generate a detailed report, outputted to ./htmlcov:

coverage html

Building documentation

Sphinx is used to build documentation

Build requirements:

How to build:

cd docs
make html

Metadata

Release files for benparse 1.0.2

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

Source distribution (sdist)

Source distribution for benparse 1.0.2
File Size Uploaded Provenance
benparse-1.0.2.tar.gz 11.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for benparse 1.0.2
File Interpreter ABI Platform
benparse-1.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 37.5 kB

Release files / benparse-1.0.2.tar.gz

Download URL benparse-1.0.2.tar.gz
Size 11.2 kB
Tags Source
SHA-256 checksum
How to use checksums
7266f97d2e547e0b22aced9f8daedc7b082ea7c5cb9f7f7103bbabf8f252d2f5
BLAKE2b-256 checksum
How to use checksums
7b6fb69c87eee406cc65145ec0ad1da975b75318be597590479658bd6edfbe45
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.5

Release files / benparse-1.0.2-py3-none-any.whl

Download URL benparse-1.0.2-py3-none-any.whl
Size 26.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
43895f2c97ed7cd8ee8d8b949205d00eb0b795c020d44f93f833a16c8cfe0aad
BLAKE2b-256 checksum
How to use checksums
dee6b8fd6414b43924c523adf5cadbbb807e5c30af56e4ae3645ffbe9f5156ac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.5

Security for benparse 1.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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