import datetime from pathlib import Path from menus import Menus class ResultFile: def __init__(self, path: Path): self.path = path def write(self, sha256: str, menus: Menus) -> None: if not self.path.exists(): self.path.write_text("") with self.path.open(mode="a") as file: file.write(f"{sha256} - {menus.date()}\n") def was_already_sent(self, sha256: str, menus: Menus): if not self.path.exists(): return False content = self.path.read_text() return f"{sha256} - {menus.date()}" in content def is_update(self, sha256: str, menus: Menus): if not self.path.exists(): return False content = self.path.read_text() return f"{sha256} - {menus.date()}" not in content and menus.date() in content