-The basic functions are bencode and bdecode. bencode takes an object
-and returns a string, bdecode takes a string and returns an object.
-bdecode raises a ValueError if you give it an invalid string.
-
-The objects passed in may be nested dicts, lists, ints, strings,
-and None. For example, all of the following may be bencoded -
-
-{'a': [0, 1], 'b': None}
-
-[None, ['a', 2, ['c', None]]]
-
-{'spam': (2,3,4)}
-
-{'name': 'Cronus', 'spouse': 'Rhea', 'children': ['Hades', 'Poseidon']}
-
-In general bdecode(bencode(spam)) == spam, but tuples and lists are
-encoded the same, so bdecode(bencode((0, 1))) is [0, 1] rather
-than (0, 1). Longs and ints are also encoded the same way, so
-bdecode(bencode(4)) is a long.
-
-dict keys are required to be strings, to avoid a mess of potential
-implementation incompatibilities. bencode is intended to be used
-for protocols which are going to be re-implemented many times, so
-it's very conservative in that regard.
-
-Which type is encoded is determined by the first character, 'i', 'n',
-'d', 'l' and any digit. They indicate integer, null, dict, list, and
-string, respectively.
-
-Strings are length-prefixed in base 10, followed by a colon.
-
-bencode('spam') == '4:spam'
-
-Nulls are indicated by a single 'n'.
-
-bencode(None) == 'n'
-
-integers are encoded base 10 and terminated with an 'e'.
-
-bencode(3) == 'i3e'
-bencode(-20) == 'i-20e'
-
-Lists are encoded in list order, terminated by an 'e' -
-
-bencode(['abc', 'd']) == 'l3:abc1:de'
-bencode([2, 'f']) == 'li2e1:fe'
-
-Dicts are encoded by containing alternating keys and values,
-with the keys in sorted order, terminated by an 'e'. For example -
-
-bencode({'spam': 'eggs'}) == 'd4:spam4:eggse'
-bencode({'ab': 2, 'a': None}) == 'd1:an2:abi2ee'
-
-Truncated strings come first, so in sort order 'a' comes before 'abc'.
-
-If a function is passed to bencode, it's called and it's return value
-is included as a raw string, for example -
-
-bdecode(bencode(lambda: None)) == None
-"""
-
-# This file is licensed under the GNU Lesser General Public License v2.1.
-# originally written for Mojo Nation by Bryce Wilcox, Bram Cohen, and Greg P. Smith
-# since then, almost completely rewritten by Bram Cohen
-
-from types import *