2023-12-10 17:32:26 +01:00
|
|
|
import re
|
|
|
|
|
|
|
|
file_name: str = "simple"
|
|
|
|
|
|
|
|
|
|
|
|
def find_pies_lines(text: str) -> list[str]:
|
|
|
|
pattern = re.compile(r"\bpies\b", re.IGNORECASE)
|
|
|
|
|
|
|
|
lines = text.split("\n")
|
|
|
|
|
2023-12-10 17:44:59 +01:00
|
|
|
pies_lines = [line for line in lines if re.search(pattern, line)]
|
2023-12-10 17:32:26 +01:00
|
|
|
|
|
|
|
return pies_lines
|
|
|
|
|
|
|
|
|
|
|
|
with open(file_name + ".in", "r", newline="", encoding="utf8") as file:
|
|
|
|
text = file.read()
|
|
|
|
|
|
|
|
with open(file_name + ".exp", "r", newline="", encoding="utf8") as file:
|
|
|
|
expected = [line.rstrip() for line in file.readlines()]
|
|
|
|
|
|
|
|
|
|
|
|
found_lines = find_pies_lines(text)
|
|
|
|
|
|
|
|
mistake = False
|
|
|
|
for line in expected:
|
|
|
|
if line in found_lines:
|
|
|
|
print(f"{line}")
|
|
|
|
else:
|
|
|
|
print(f"NO: {line}")
|
|
|
|
mistake = True
|
|
|
|
|
|
|
|
if mistake:
|
|
|
|
print("ERROR")
|