static-http 0.1.4__tar.gz → 0.1.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {static_http-0.1.4/src/static_http.egg-info → static_http-0.1.5}/PKG-INFO +1 -1
- {static_http-0.1.4 → static_http-0.1.5}/pyproject.toml +1 -1
- {static_http-0.1.4 → static_http-0.1.5}/src/http_here/__init__.py +1 -1
- {static_http-0.1.4 → static_http-0.1.5}/src/http_here/qrcode.py +35 -65
- {static_http-0.1.4 → static_http-0.1.5/src/static_http.egg-info}/PKG-INFO +1 -1
- {static_http-0.1.4 → static_http-0.1.5}/tests/test_qrcode.py +59 -0
- {static_http-0.1.4 → static_http-0.1.5}/LICENSE +0 -0
- {static_http-0.1.4 → static_http-0.1.5}/README.md +0 -0
- {static_http-0.1.4 → static_http-0.1.5}/setup.cfg +0 -0
- {static_http-0.1.4 → static_http-0.1.5}/src/http_here/__main__.py +0 -0
- {static_http-0.1.4 → static_http-0.1.5}/src/http_here/cli.py +0 -0
- {static_http-0.1.4 → static_http-0.1.5}/src/http_here/keyboard.py +0 -0
- {static_http-0.1.4 → static_http-0.1.5}/src/http_here/ranges.py +0 -0
- {static_http-0.1.4 → static_http-0.1.5}/src/http_here/server.py +0 -0
- {static_http-0.1.4 → static_http-0.1.5}/src/http_here/urls.py +0 -0
- {static_http-0.1.4 → static_http-0.1.5}/src/static_http.egg-info/SOURCES.txt +0 -0
- {static_http-0.1.4 → static_http-0.1.5}/src/static_http.egg-info/dependency_links.txt +0 -0
- {static_http-0.1.4 → static_http-0.1.5}/src/static_http.egg-info/entry_points.txt +0 -0
- {static_http-0.1.4 → static_http-0.1.5}/src/static_http.egg-info/requires.txt +0 -0
- {static_http-0.1.4 → static_http-0.1.5}/src/static_http.egg-info/top_level.txt +0 -0
- {static_http-0.1.4 → static_http-0.1.5}/tests/test_cli.py +0 -0
- {static_http-0.1.4 → static_http-0.1.5}/tests/test_ranges.py +0 -0
- {static_http-0.1.4 → static_http-0.1.5}/tests/test_server.py +0 -0
- {static_http-0.1.4 → static_http-0.1.5}/tests/test_urls.py +0 -0
|
@@ -36,37 +36,28 @@ def _gf_mul(x: int, y: int) -> int:
|
|
|
36
36
|
return result
|
|
37
37
|
|
|
38
38
|
|
|
39
|
-
def _gf_pow(x: int, power: int) -> int:
|
|
40
|
-
result = 1
|
|
41
|
-
for _ in range(power):
|
|
42
|
-
result = _gf_mul(result, x)
|
|
43
|
-
return result
|
|
44
|
-
|
|
45
|
-
|
|
46
39
|
def _generator_poly(degree: int) -> list[int]:
|
|
47
|
-
result = [
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
for j, right_value in enumerate(right):
|
|
57
|
-
result[i + j] ^= _gf_mul(left_value, right_value)
|
|
40
|
+
result = [0] * degree
|
|
41
|
+
result[-1] = 1
|
|
42
|
+
root = 1
|
|
43
|
+
for _ in range(degree):
|
|
44
|
+
for i in range(degree):
|
|
45
|
+
result[i] = _gf_mul(result[i], root)
|
|
46
|
+
if i + 1 < degree:
|
|
47
|
+
result[i] ^= result[i + 1]
|
|
48
|
+
root = _gf_mul(root, 0x02)
|
|
58
49
|
return result
|
|
59
50
|
|
|
60
51
|
|
|
61
52
|
def _reed_solomon(data: list[int], degree: int) -> list[int]:
|
|
62
|
-
|
|
63
|
-
result =
|
|
64
|
-
for
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
for
|
|
68
|
-
result[i
|
|
69
|
-
return result
|
|
53
|
+
divisor = _generator_poly(degree)
|
|
54
|
+
result = [0] * degree
|
|
55
|
+
for byte in data:
|
|
56
|
+
factor = byte ^ result.pop(0)
|
|
57
|
+
result.append(0)
|
|
58
|
+
for i, coefficient in enumerate(divisor):
|
|
59
|
+
result[i] ^= _gf_mul(coefficient, factor)
|
|
60
|
+
return result
|
|
70
61
|
|
|
71
62
|
|
|
72
63
|
def _append_bits(bits: list[int], value: int, length: int) -> None:
|
|
@@ -139,7 +130,6 @@ def _draw_function_patterns(matrix: list[list[bool | None]], function: list[list
|
|
|
139
130
|
_set_function(matrix, function, 6, i, i % 2 == 0)
|
|
140
131
|
_set_function(matrix, function, i, 6, i % 2 == 0)
|
|
141
132
|
|
|
142
|
-
_set_function(matrix, function, size - 8, 8, True)
|
|
143
133
|
_draw_format_bits(matrix, function, 0)
|
|
144
134
|
|
|
145
135
|
|
|
@@ -199,44 +189,24 @@ def _format_bits(mask: int) -> int:
|
|
|
199
189
|
def _draw_format_bits(matrix: list[list[bool | None]], function: list[list[bool]], mask: int) -> None:
|
|
200
190
|
bits = _format_bits(mask)
|
|
201
191
|
size = len(matrix)
|
|
202
|
-
|
|
203
|
-
(
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
(size - 1, 8),
|
|
221
|
-
(size - 2, 8),
|
|
222
|
-
(size - 3, 8),
|
|
223
|
-
(size - 4, 8),
|
|
224
|
-
(size - 5, 8),
|
|
225
|
-
(size - 6, 8),
|
|
226
|
-
(size - 7, 8),
|
|
227
|
-
(8, size - 8),
|
|
228
|
-
(8, size - 7),
|
|
229
|
-
(8, size - 6),
|
|
230
|
-
(8, size - 5),
|
|
231
|
-
(8, size - 4),
|
|
232
|
-
(8, size - 3),
|
|
233
|
-
(8, size - 2),
|
|
234
|
-
(8, size - 1),
|
|
235
|
-
]
|
|
236
|
-
for i, (row, col) in enumerate(positions_a):
|
|
237
|
-
_set_function(matrix, function, row, col, ((bits >> i) & 1) == 1)
|
|
238
|
-
for i, (row, col) in enumerate(positions_b):
|
|
239
|
-
_set_function(matrix, function, row, col, ((bits >> i) & 1) == 1)
|
|
192
|
+
for i in range(15):
|
|
193
|
+
dark = ((bits >> i) & 1) == 1
|
|
194
|
+
|
|
195
|
+
if i < 6:
|
|
196
|
+
_set_function(matrix, function, i, 8, dark)
|
|
197
|
+
elif i < 8:
|
|
198
|
+
_set_function(matrix, function, i + 1, 8, dark)
|
|
199
|
+
else:
|
|
200
|
+
_set_function(matrix, function, size - 15 + i, 8, dark)
|
|
201
|
+
|
|
202
|
+
if i < 8:
|
|
203
|
+
_set_function(matrix, function, 8, size - i - 1, dark)
|
|
204
|
+
elif i == 8:
|
|
205
|
+
_set_function(matrix, function, 8, 7, dark)
|
|
206
|
+
else:
|
|
207
|
+
_set_function(matrix, function, 8, 14 - i, dark)
|
|
208
|
+
|
|
209
|
+
_set_function(matrix, function, size - 8, 8, True)
|
|
240
210
|
|
|
241
211
|
|
|
242
212
|
def _penalty(matrix: list[list[bool | None]]) -> int:
|
|
@@ -45,6 +45,65 @@ def test_qr_known_format_bits_and_version_selection() -> None:
|
|
|
45
45
|
assert len(qrcode._build_matrix("http://192.168.1.205:8080/")) == 25
|
|
46
46
|
|
|
47
47
|
|
|
48
|
+
def test_reed_solomon_matches_known_version_2_l_codewords() -> None:
|
|
49
|
+
data = qrcode._encode_data(b"http://localhost:8080/", 2)
|
|
50
|
+
|
|
51
|
+
assert data == [
|
|
52
|
+
65,
|
|
53
|
+
102,
|
|
54
|
+
135,
|
|
55
|
+
71,
|
|
56
|
+
71,
|
|
57
|
+
3,
|
|
58
|
+
162,
|
|
59
|
+
242,
|
|
60
|
+
246,
|
|
61
|
+
198,
|
|
62
|
+
246,
|
|
63
|
+
54,
|
|
64
|
+
22,
|
|
65
|
+
198,
|
|
66
|
+
134,
|
|
67
|
+
247,
|
|
68
|
+
55,
|
|
69
|
+
67,
|
|
70
|
+
163,
|
|
71
|
+
131,
|
|
72
|
+
3,
|
|
73
|
+
131,
|
|
74
|
+
2,
|
|
75
|
+
240,
|
|
76
|
+
236,
|
|
77
|
+
17,
|
|
78
|
+
236,
|
|
79
|
+
17,
|
|
80
|
+
236,
|
|
81
|
+
17,
|
|
82
|
+
236,
|
|
83
|
+
17,
|
|
84
|
+
236,
|
|
85
|
+
17,
|
|
86
|
+
]
|
|
87
|
+
assert qrcode._reed_solomon(data, qrcode._ECC_CODEWORDS[2]) == [224, 235, 163, 25, 95, 161, 5, 47, 66, 94]
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def test_format_bits_use_dark_module_and_second_copy_positions() -> None:
|
|
91
|
+
size = 25
|
|
92
|
+
matrix = [[None for _ in range(size)] for _ in range(size)]
|
|
93
|
+
function = [[False for _ in range(size)] for _ in range(size)]
|
|
94
|
+
|
|
95
|
+
qrcode._draw_function_patterns(matrix, function, 2)
|
|
96
|
+
qrcode._draw_format_bits(matrix, function, 4)
|
|
97
|
+
bits = qrcode._format_bits(4)
|
|
98
|
+
|
|
99
|
+
assert matrix[size - 8][8] is True
|
|
100
|
+
assert matrix[0][8] == bool(bits & 1)
|
|
101
|
+
assert matrix[8][size - 1] == bool(bits & 1)
|
|
102
|
+
assert matrix[8][7] == bool((bits >> 8) & 1)
|
|
103
|
+
assert matrix[size - 1][8] == bool(bits & 1)
|
|
104
|
+
assert function[size - 8][8] is True
|
|
105
|
+
|
|
106
|
+
|
|
48
107
|
def test_qr_warns_when_terminal_too_narrow() -> None:
|
|
49
108
|
fake_size = namedtuple("Size", "columns lines")(20, 24)
|
|
50
109
|
monkeypatch = pytest.MonkeyPatch()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|