all repos — mycal @ a9a78d3d447a6045232bc807d5bba50791c17c9f

private calendar anonymiser

workaround weirdness in toml-dataclass

Alan Pearce
commit

a9a78d3d447a6045232bc807d5bba50791c17c9f

parent

16b35a5239f20fdcde8430cb325cfce90e3a6788

1 file changed, 13 insertions(+), 4 deletions(-)

changed files
M mycal.pymycal.py
@@ -12,7 +12,7 @@ from uuid import uuid4
import aiohttp import icalendar -from danoan.toml_dataclass import TomlDataClassIO +from danoan.toml_dataclass import TomlDataClassIO, TomlTableDataClassIO from icalendar.cal import Calendar, FreeBusy from quart import Quart
@@ -25,6 +25,10 @@ url: str | None = None
all_tentative: bool = False @dataclass +class Calendars(TomlTableDataClassIO): + calendars: list[CalendarConfig] + +@dataclass class Config(TomlDataClassIO): name: str email: str
@@ -34,10 +38,15 @@ calendars: list[CalendarConfig] = field(default_factory=list)
def load_config(file_path: str): with open(file_path, "r") as fr: - c = Config.read(fr) - if c is None: + cfg = Config.read(fr) + if cfg is None: raise ValueError("Failed to load configuration") - return c + _ = fr.seek(0) + cals = Calendars.read(fr) + if cals is None: + raise ValueError("Failed to load calendars") + cfg.calendars = cals.calendars + return cfg app = Quart(__name__)