mirror of
https://github.com/scito/extract_otp_secret_keys.git
synced 2025-12-05 22:34:57 +01:00
fix Python 3.7 compatibility
This commit is contained in:
parent
6cfbc10e69
commit
66c68fd9ef
2 changed files with 8 additions and 6 deletions
|
|
@ -240,11 +240,13 @@ def cv2_draw_box(img: Any, raw_pts: Any, color: ColorBGR) -> Any:
|
|||
|
||||
# TODO use cv2 types if available
|
||||
def cv2_print_text(img: Any, text: str, line_number: int, position: TextPosition, color: ColorBGR, opposite_len: Optional[int] = None) -> None:
|
||||
text_dim, _ = cv2.getTextSize(text, FONT, FONT_SCALE, FONT_THICKNESS)
|
||||
window_dim = cv2.getWindowImageRect(WINDOW_NAME)
|
||||
out_text = text \
|
||||
if not opposite_len or (actual_width := text_dim[TEXT_WIDTH] + opposite_len * CHAR_DX + 4 * BORDER) <= window_dim[WINDOW_WIDTH] \
|
||||
else text[:(window_dim[WINDOW_WIDTH] - actual_width) // CHAR_DX] + '.'
|
||||
out_text = text
|
||||
if opposite_len:
|
||||
text_dim, _ = cv2.getTextSize(out_text, FONT, FONT_SCALE, FONT_THICKNESS)
|
||||
actual_width = text_dim[TEXT_WIDTH] + opposite_len * CHAR_DX + 4 * BORDER
|
||||
if actual_width >= window_dim[WINDOW_WIDTH]:
|
||||
out_text = out_text[:(window_dim[WINDOW_WIDTH] - actual_width) // CHAR_DX] + '.'
|
||||
text_dim, _ = cv2.getTextSize(out_text, FONT, FONT_SCALE, FONT_THICKNESS)
|
||||
if position == TextPosition.LEFT:
|
||||
pos = BORDER, START_Y + line_number * FONT_DY
|
||||
|
|
|
|||
|
|
@ -413,8 +413,8 @@ def test_extract_verbose(verbose_level: str, color: str, capsys: pytest.CaptureF
|
|||
# Assert
|
||||
captured = capsys.readouterr()
|
||||
|
||||
expected_stdout = normalize_verbose_text(read_file_to_str(f'tests/data/print_verbose_output{color}{verbose_level}.txt'), actual_relaxed := relaxed or sys.implementation.name == 'pypy')
|
||||
actual_stdout = normalize_verbose_text(captured.out, actual_relaxed)
|
||||
expected_stdout = normalize_verbose_text(read_file_to_str(f'tests/data/print_verbose_output{color}{verbose_level}.txt'), relaxed or sys.implementation.name == 'pypy')
|
||||
actual_stdout = normalize_verbose_text(captured.out, relaxed or sys.implementation.name == 'pypy')
|
||||
|
||||
assert actual_stdout == expected_stdout
|
||||
assert captured.err == ''
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue