mirror of
https://github.com/scito/extract_otp_secret_keys.git
synced 2025-12-12 17:46:36 +01:00
fix fileinput.input encoding only since Python 3.10
This commit is contained in:
parent
003e122808
commit
869c404489
2 changed files with 7 additions and 2 deletions
|
|
@ -343,7 +343,11 @@ def get_otp_urls_from_file(filename: str, args: Args) -> OtpUrls:
|
||||||
|
|
||||||
def read_lines_from_text_file(filename: str) -> list[str]:
|
def read_lines_from_text_file(filename: str) -> list[str]:
|
||||||
if verbose: print(f"Reading lines of {filename}")
|
if verbose: print(f"Reading lines of {filename}")
|
||||||
finput = fileinput.input(filename, encoding='utf-8')
|
# PYTHON >= 3.10 support encoding
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
finput = fileinput.input(filename, encoding='utf-8')
|
||||||
|
else:
|
||||||
|
finput = fileinput.input(filename)
|
||||||
try:
|
try:
|
||||||
lines = []
|
lines = []
|
||||||
for line in (line.strip() for line in finput):
|
for line in (line.strip() for line in finput):
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ qreader_available: bool = extract_otp_secrets.qreader_available
|
||||||
|
|
||||||
|
|
||||||
# Quickfix comment
|
# Quickfix comment
|
||||||
# @pytest.mark.skipif(sys.platform.startswith("win") or not qreader_available or sys.implementation.name == 'pypy', reason="Quickfix")
|
# @pytest.mark.skipif(sys.platform.startswith("win") or not qreader_available or sys.implementation.name == 'pypy' or sys.version_info >= (3, 10), reason="Quickfix")
|
||||||
|
|
||||||
|
|
||||||
def test_extract_stdout(capsys: pytest.CaptureFixture[str]) -> None:
|
def test_extract_stdout(capsys: pytest.CaptureFixture[str]) -> None:
|
||||||
|
|
@ -356,6 +356,7 @@ def test_normalize_bytes() -> None:
|
||||||
|
|
||||||
|
|
||||||
# Generate verbose output: python3.11 src/extract_otp_secrets.py example_export.txt -v -n > tests/data/print_verbose_output.txt
|
# Generate verbose output: python3.11 src/extract_otp_secrets.py example_export.txt -v -n > tests/data/print_verbose_output.txt
|
||||||
|
@pytest.mark.skipif(sys.version_info < (3, 10), reason="fileinput.input encoding exists since PYTHON 3.10")
|
||||||
def test_extract_verbose(capsys: pytest.CaptureFixture[str], relaxed: bool) -> None:
|
def test_extract_verbose(capsys: pytest.CaptureFixture[str], relaxed: bool) -> None:
|
||||||
# Act
|
# Act
|
||||||
extract_otp_secrets.main(['-n', '-v', 'example_export.txt'])
|
extract_otp_secrets.main(['-n', '-v', 'example_export.txt'])
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue