Skip to main content

Simple bencode parser (for Python 2, Python 3 and PyPy)

Project description

https://img.shields.io/pypi/v/bencode.py.svg?style=flat-square https://img.shields.io/travis/fuzeman/bencode.py.svg?style=flat-square https://img.shields.io/coveralls/fuzeman/bencode.py/master.svg?style=flat-square

Simple bencode parser (for Python 2, Python 3 and PyPy), forked from the bencode package by Thomas Rampelberg.

Usage

Encode:

import bencode

bencode.encode({'title': 'Example'})
# 'd5:title7:Examplee'

bencode.encode(12)
# 'i12e'

Decode:

import bencode

bencode.decode('d5:title7:Examplee')
# {'title': 'Example'}

bencode.decode('i12e')
# 12

API

bencode.bencode(value)

bencode.encode(value)

Encode value into the bencode format.

bencode.bdecode(value)

bencode.decode(value)

Decode bencode formatted string value.

bencode.bread(fd)

Read bencode formatted string from file or path fd.

bencode.bwrite(data, fd)

Write data as a bencode formatted string to file or path fd.

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

bencode.py-2.0.0.tar.gz (7.3 kB view hashes)

Uploaded Source

Built Distribution

bencode.py-2.0.0-py2.py3-none-any.whl (6.4 kB view hashes)

Uploaded Python 2 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