YABEncode - Yet Another Bencode module
Project description
An implementation of bencoding/bdecoding in Python 3, with somewhat descriptive Exceptions for decode errors.
Installing
To install from PyPI:
pip install yabencode
Usage:
import yabencode
# bencode supports dicts, lists, ints and strings (bytestrings)
yabencode.encode({'foo':'baz', 'list':['eggs', 'spam', 'bacon']})
# Input can be string, bytes or a file object
yabencode.decode(b'd3:foo3:baz4:listl4:eggs4:spam5:baconee')
try:
# Malformed data, 'spam' is missing an 'a'
yabencode.decode(b'd3:foo3:baz4:listl4:eggs4:spm5:baconee')
except yabencode.MalformedBencodeException as e:
print(e)
# Unexpected data type (b':') at position 31 (0x1F hex)
try:
# Bencode does not support floats
yabencode.encode({'float':3.14})
except yabencode.BencodeException as e:
print(e)
# Unsupported type <class 'float'>
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Close
Hashes for yabencode-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9ae6b9211fd5a2b8212d55a3e1e58cc17791bd8e869c9b6541a9332abb3cdde8 |
|
MD5 | 620983e39d5e359a2c61be672323d9a9 |
|
BLAKE2b-256 | f14b2779d719a9c7d54b3a96e6ec5b2e7ab5bb72f58d979d8d0f3f3ca7711051 |