-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
35 lines (28 loc) · 1.1 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
"""Main app exec"""
import logging
from passwordchecker.validators import PasswordValidator
from passwordchecker.validation_errors import ValidationException
logging.basicConfig(level=logging.INFO)
def parse_from_file(input_file: str, output_file: str):
"""test multiple passwords taken from the input file against being pwnd.
Save good passwords to the output file"""
with open(input_file, encoding="utf-8") as file, open(
output_file, mode="w", encoding="utf-8"
) as output:
counter = 1
for line in file:
try:
password = PasswordValidator(line.strip())
password.is_valid()
output.write(line)
except ValidationException as error:
logging.info(
"Line %s: Bad password: %s", counter, error.__class__.__name__
)
finally:
counter += 1
def main():
"""main app call. Uses passwords.txt file as input and bezpieczne.txt as output"""
parse_from_file("passwords.txt", "bezpieczne.txt")
if __name__ == "__main__":
main()