mirror of
https://github.com/scito/extract_otp_secret_keys.git
synced 2025-12-06 06:44:57 +01:00
parent
7af4017910
commit
a51507b701
4 changed files with 6 additions and 7 deletions
|
|
@ -305,7 +305,7 @@ def open_file_or_stdout(filename):
|
|||
'''stdout is denoted as "-".
|
||||
Note: Set before the following line:
|
||||
sys.stdout.close = lambda: None'''
|
||||
return open(filename, "w") if filename != '-' else sys.stdout
|
||||
return open(filename, "w", encoding='utf-8') if filename != '-' else sys.stdout
|
||||
|
||||
|
||||
def open_file_or_stdout_for_csv(filename):
|
||||
|
|
@ -313,7 +313,7 @@ def open_file_or_stdout_for_csv(filename):
|
|||
newline=''
|
||||
Note: Set before the following line:
|
||||
sys.stdout.close = lambda: None'''
|
||||
return open(filename, "w", newline='') if filename != '-' else sys.stdout
|
||||
return open(filename, "w", encoding='utf-8', newline='') if filename != '-' else sys.stdout
|
||||
|
||||
|
||||
def eprint(*args, **kwargs):
|
||||
|
|
|
|||
|
|
@ -270,7 +270,7 @@ Type: totp
|
|||
assert captured.out == expected_stdout
|
||||
assert captured.err == ''
|
||||
|
||||
@mark.skipif(platform.startswith("win"), reason="This test is not supported on Windows.")
|
||||
|
||||
def test_extract_printqr(capsys):
|
||||
# Act
|
||||
extract_otp_secret_keys.main(['-p', 'example_export.txt'])
|
||||
|
|
|
|||
|
|
@ -140,7 +140,6 @@ Type: totp
|
|||
self.assertEqual(actual_output, expected_output)
|
||||
|
||||
def test_extract_printqr(self):
|
||||
if platform.startswith("win"): self.skipTest("This test is not supported on Windows.")
|
||||
out = io.StringIO()
|
||||
with redirect_stdout(out):
|
||||
extract_otp_secret_keys.main(['-p', 'example_export.txt'])
|
||||
|
|
|
|||
6
utils.py
6
utils.py
|
|
@ -59,7 +59,7 @@ def remove_dir_with_files(dir):
|
|||
|
||||
def read_csv(filename):
|
||||
"""Returns a list of lines."""
|
||||
with open(filename, "r", newline='') as infile:
|
||||
with open(filename, "r", encoding="utf-8", newline='') as infile:
|
||||
lines = []
|
||||
reader = csv.reader(infile)
|
||||
for line in reader:
|
||||
|
|
@ -78,7 +78,7 @@ def read_csv_str(str):
|
|||
|
||||
def read_json(filename):
|
||||
"""Returns a list or a dictionary."""
|
||||
with open(filename, "r") as infile:
|
||||
with open(filename, "r", encoding="utf-8") as infile:
|
||||
return json.load(infile)
|
||||
|
||||
|
||||
|
|
@ -89,7 +89,7 @@ def read_json_str(str):
|
|||
|
||||
def read_file_to_list(filename):
|
||||
"""Returns a list of lines."""
|
||||
with open(filename, "r") as infile:
|
||||
with open(filename, "r", encoding="utf-8") as infile:
|
||||
return infile.readlines()
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue