workaround weirdness in toml-dataclass
1 file changed, 13 insertions(+), 4 deletions(-)
changed files
M mycal.py → mycal.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__)