put trace in a result file

This commit is contained in:
Stanislas Jouffroy 2025-05-21 00:33:56 +02:00
parent 618213572f
commit e042263871
3 changed files with 47 additions and 43 deletions

20
result_file.py Normal file
View file

@ -0,0 +1,20 @@
from pathlib import Path
class ResultFile:
def __init__(self, path: Path):
self.path = path
def write(self, creation_date: str, modification_date: str, menu_type: str) -> None:
if not self.path.exists():
self.path.write_text("")
with self.path.open(mode="a") as file:
file.write(f"{creation_date}/{modification_date}/{menu_type}\n")
def was_already_sent(
self, creation_date: str, modification_date: str, menu_type: str
):
if not self.path.exists():
return False
content = self.path.read_text()
return f"{creation_date}/{modification_date}/{menu_type}\n" in content