Metadata-Version: 2.4
Name: bencode.py
Version: 2.1.0
Summary: Simple bencode parser (for Python 2, Python 3 and PyPy)
Home-page: https://github.com/fuzeman/bencode.py
Author: Dean Gardiner
Author-email: me@dgardiner.net
License: BitTorrent Open Source License
Keywords: bittorrent,bencode,bdecode
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: Other/Proprietary License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.6
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Topic :: Software Development :: Libraries
License-File: LICENSE
License-File: AUTHORS
License-File: AUTHORS.in
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: home-page
Dynamic: keywords
Dynamic: license
Dynamic: license-file
Dynamic: summary

bencode.py
==========

.. image:: https://img.shields.io/pypi/v/bencode.py.svg?style=flat-square
   :target: https://pypi.python.org/pypi/bencode.py

.. image:: https://img.shields.io/travis/fuzeman/bencode.py.svg?style=flat-square
   :target: https://travis-ci.org/fuzeman/bencode.py

.. image:: https://img.shields.io/coveralls/fuzeman/bencode.py/master.svg?style=flat-square
   :target: https://coveralls.io/github/fuzeman/bencode.py

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

__ https://pypi.python.org/pypi/bencode


Usage
-----

**Encode:**

.. code-block:: python

    import bencode

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

    bencode.encode(12)
    # 'i12e'

**Decode:**

.. code-block:: python

    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``.

