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