Skip to content

Commit 880a39b

Browse files
committed
auto push commit coverage
1 parent b96b39d commit 880a39b

14 files changed

Lines changed: 596 additions & 574 deletions

.prospector.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
strictness: high
2+
autodetect: true
3+
doc-warnings: true
4+
test-warnings: true
5+
member-warnings: true
6+
7+
pep257:
8+
run: true
9+
disable:
10+
- D203
11+
- D212
12+
- D213
13+
- D413
14+
15+
pep8:
16+
run: true
17+
18+
pylint:
19+
run: true
20+
21+
bandit:
22+
run: true
23+
24+
pyroma:
25+
run: true
26+
27+
pyflakes:
28+
run: true

Makefile

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,19 @@ lint: ## check style with flake8
5252
pyroma .
5353
bandit pyben/*
5454
pep257 pyben
55+
prospector pyben
56+
prospector tests
5557

5658
test: ## run tests quickly with the default Python
5759
pytest tests
58-
pytest --coverage tests
59-
pytest --pylint tests
60+
pytest tests --cov
61+
pytest tests --pylint
6062

6163
coverage: ## check code coverage quickly with the default Python
62-
coverage run -m pytest tests
64+
coverage run -m pytest tests --cov --pylint
6365
coverage xml -o coverage.xml
6466

65-
push: clean lint docs coverage
67+
push: lint docs clean test coverage
6668
git add .
6769
git commit -m "auto push commit coverage"
6870
git push

docs/api/index.html

Lines changed: 346 additions & 396 deletions
Large diffs are not rendered by default.

docs/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,5 +257,5 @@ <h4 class="modal-title" id="keyboardModalLabel">Keyboard Shortcuts</h4>
257257

258258
<!--
259259
MkDocs version : 1.2.2
260-
Build Date UTC : 2021-10-10 02:34:11.330781+00:00
260+
Build Date UTC : 2021-10-10 03:52:47.654511+00:00
261261
-->

docs/search/search_index.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

docs/sitemap.xml.gz

0 Bytes
Binary file not shown.

pyben/api.py

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,13 @@ def dump(obj, buffer):
7272
Works effectively the same as it's json equivelant except also
7373
accepts a path as well as an open fileIO.
7474
75-
Args
76-
-----------------
75+
Args:
76+
----
7777
obj : any
78-
* Data to be encoded.
78+
Data to be encoded.
7979
buffer : `str` or `BytesIO`
80-
* File of path-like to write the data to.
80+
File of path-like to write the data to.
81+
8182
"""
8283
encoded = benencode(obj)
8384

@@ -95,14 +96,15 @@ def dumps(obj):
9596
Shortuct function to encoding given obj to bencode encoding.
9697
9798
Args
98-
--------
99+
----
99100
obj : `any`
100-
* Object to be encoded.py.
101+
Object to be encoded.py.
101102
102103
Returns
103-
--------
104+
-------
104105
`bytes` :
105-
* Encoded data.
106+
Encoded data.
107+
106108
"""
107109
return benencode(obj)
108110

@@ -112,14 +114,15 @@ def load(buffer):
112114
Load bencoded data from a file of path object and decodes it.
113115
114116
Args
115-
--------
117+
----
116118
buffer : `str` or `BytesIO`
117-
* Open and/or read data from file to be decoded.
119+
Open and/or read data from file to be decoded.
118120
119121
Returns
120-
---------
122+
-------
121123
`any` :
122-
* (commonly `dict`), Decoded contents of file.
124+
(commonly `dict`), Decoded contents of file.
125+
123126
"""
124127
if hasattr(buffer, "read"):
125128
decoded, _ = bendecode(buffer.read())
@@ -136,14 +139,15 @@ def loads(encoded):
136139
Shortcut function for decoding encoded data.
137140
138141
Args
139-
--------
142+
----
140143
encoded : `bytes`
141-
* Bencoded data.
144+
Bencoded data.
142145
143146
Returns
144-
--------
147+
-------
145148
`any` :
146-
* (commonly `dict`), Decoded data.
149+
(commonly `dict`), Decoded data.
150+
147151
"""
148152
decoded, _ = bendecode(encoded)
149153
return decoded

pyben/bencode.py

Lines changed: 59 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)