@@ -41,19 +41,20 @@ def bendecode(bits):
4141 Decode bencoded data.
4242
4343 Args
44- -----------------
44+ ----
4545 bits : `bytes`
46- > Bencode encoded data.
46+ Bencode encoded data.
4747
4848 Raises
49- -----------------
49+ ------
5050 `DecodeError` :
51- > Malformed data.
51+ Malformed data.
5252
5353 Returns
54- -----------------
54+ -------
5555 any :
56- > Bencode decoded data.
56+ Bencode decoded data.
57+
5758 """
5859 if bits .startswith (b"i" ):
5960 match , feed = bendecode_int (bits )
@@ -79,14 +80,15 @@ def bendecode_str(units):
7980 Bendecode string types.
8081
8182 Args
82- ---------
83+ ----
8384 bits : `bytes`
84- > Bencoded string.
85+ Bencoded string.
8586
8687 Returns
87- ---------
88+ -------
8889 `str` :
89- > Decoded data string.
90+ Decoded data string.
91+
9092 """
9193 match = re .match (br"(\d+):" , units )
9294 word_len , start = int (match .groups ()[0 ]), match .span ()[1 ]
@@ -107,14 +109,15 @@ def bendecode_int(bits):
107109 Decode digits.
108110
109111 Args
110- -----------------
112+ ----
111113 bits : `bytes`
112- > Bencoded intiger bytes
114+ Bencoded intiger bytes
113115
114116 Returns
115- -----------------
117+ -------
116118 `int` :
117- > Decoded int value.
119+ Decoded int value.
120+
118121 """
119122 obj = re .match (br"i(-?\d+)e" , bits )
120123 return int (obj .group (1 )), obj .end ()
@@ -125,14 +128,15 @@ def bendecode_dict(bits):
125128 Decode dictionary and it's contents.
126129
127130 Args
128- ---------
131+ ----
129132 bits : `bytes`
130- > Bencoded dictionary.
133+ Bencoded dictionary.
131134
132135 Returns
133- ---------
136+ -------
134137 `dict`
135- > Decoded dictionary and contents
138+ Decoded dictionary and contents
139+
136140 """
137141 dic , feed = {}, 1
138142
@@ -152,14 +156,15 @@ def bendecode_list(bits):
152156 Decode list and list contents.
153157
154158 Args
155- -----------------
159+ ----
156160 bits : `bytes`
157- > Bencoded list.
161+ Bencoded list.
158162
159163 Returns
160- -----------------
164+ -------
161165 `list` :
162- > Bencode decoded list and contents.
166+ Bencode decoded list and contents.
167+
163168 """
164169 lst , feed = [], 1
165170
@@ -177,19 +182,20 @@ def benencode(val):
177182 Encode data with bencoding.
178183
179184 Args
180- --------
185+ ----
181186 val : any
182- > Data for encoding.
187+ Data for encoding.
183188
184189 Raises
185- --------
190+ ------
186191 `EncodeError` :
187- > Cannot interpret data.
192+ Cannot interpret data.
188193
189194 Returns
190- ---------
195+ -------
191196 `bytes` :
192- > Bencoded data.
197+ Bencoded data.
198+
193199 """
194200 if isinstance (val , str ):
195201 return bencode_str (val )
@@ -217,14 +223,15 @@ def bencode_bytes(bits):
217223 Encode bytes.
218224
219225 Args
220- --------
226+ ----
221227 bits : `bytes`
222- > Bytes treated as a byte-string literal.
228+ Bytes treated as a byte-string literal.
223229
224230 Returns
225- ---------
231+ -------
226232 `bytes`:
227- > Bencode encoded byte string literal.
233+ Bencode encoded byte string literal.
234+
228235 """
229236 size = str (len (bits )) + ":"
230237 return size .encode ("utf-8" ) + bits
@@ -235,14 +242,15 @@ def bencode_str(txt):
235242 Encode string literals.
236243
237244 Args
238- --------
245+ ----
239246 txt : `str`
240- > Any text string.
247+ Any text string.
241248
242249 Returns
243- ---------
250+ -------
244251 `bytes` :
245- > Bencoded string literal.
252+ Bencoded string literal.
253+
246254 """
247255 size = str (len (txt )) + ":"
248256 return size .encode ("utf-8" ) + txt .encode ("utf-8" )
@@ -253,14 +261,15 @@ def bencode_int(i):
253261 Encode integer type.
254262
255263 Args
256- --------
264+ ----
257265 i : `int`
258- > Number that needs encoding.
266+ Number that needs encoding.
259267
260268 Returns
261- ---------
269+ -------
262270 `bytes` :
263- > Bencoded Integer.
271+ Bencoded Integer.
272+
264273 """
265274 return ("i" + str (i ) + "e" ).encode ("utf-8" )
266275
@@ -270,14 +279,15 @@ def bencode_list(elems):
270279 Encode list and contents.
271280
272281 Args
273- --------
282+ ----
274283 elems : `list`
275- > List of items for bencoding.
284+ List of items for bencoding.
276285
277286 Returns
278- ---------
287+ -------
279288 `bytes` :
280- > Bencoded list and contents.
289+ Bencoded list and contents.
290+
281291 """
282292 arr = bytearray ("l" , encoding = "utf-8" )
283293
@@ -294,14 +304,15 @@ def bencode_dict(dic):
294304 Encode dictionary and contents.
295305
296306 Args
297- --------
307+ ----
298308 dic : `dict`
299- > Any dictionary containing items that can be bencoded.
309+ Any dictionary containing items that can be bencoded.
300310
301311 Returns
302- ---------
312+ -------
303313 `bytes` :
304- > Bencoded key, value pairs of data.
314+ Bencoded key, value pairs of data.
315+
305316 """
306317 result = b"d"
307318
0 commit comments