config documentation

This commit is contained in:
Jörn-Michael Miehe 2022-09-09 14:12:36 +00:00
parent 72e3324141
commit 0cdf49cf3e
3 changed files with 11 additions and 5 deletions

View file

@ -21,6 +21,8 @@ _logger = getLogger(__name__)
class TickerAPIConfig(BaseModel): class TickerAPIConfig(BaseModel):
""" """
Section "[ticker.api]" in "config.txt". Section "[ticker.api]" in "config.txt".
Configuration for how the API generates the ticker content.
""" """
file_name: str = "ticker" file_name: str = "ticker"
@ -31,6 +33,8 @@ class TickerAPIConfig(BaseModel):
class TickerUIConfig(BaseModel): class TickerUIConfig(BaseModel):
""" """
Section "[ticker.ui]" in "config.txt". Section "[ticker.ui]" in "config.txt".
Configuration for how the UI displays the ticker content.
""" """
display: bool = True display: bool = True
@ -41,6 +45,8 @@ class TickerUIConfig(BaseModel):
class TickerConfig(BaseModel): class TickerConfig(BaseModel):
""" """
Section "[ticker]" in "config.txt". Section "[ticker]" in "config.txt".
Combined configuration for the ticker.
""" """
api: TickerAPIConfig = TickerAPIConfig() api: TickerAPIConfig = TickerAPIConfig()
@ -61,11 +67,11 @@ class ImageConfig(BaseModel):
class CalendarConfig(BaseModel): class CalendarConfig(BaseModel):
""" """
Section "[calendar]" in "config.txt". Sections "[calendar*]" in "config.txt".
""" """
future_days: int = 365 future_days: int = 365
aggregate: dict[str, list[str]] = {} aggregates: dict[str, list[str]] = {}
class Config(BaseModel): class Config(BaseModel):
@ -99,7 +105,7 @@ class Config(BaseModel):
) )
cfg = cls() cfg = cls()
cfg.calendar.aggregate["All Events"] = list(await caldav_list()) cfg.calendar.aggregates["All Events"] = list(await caldav_list())
buffer = BytesIO() buffer = BytesIO()
toml_dump(cfg.dict(), buffer) toml_dump(cfg.dict(), buffer)

View file

@ -96,7 +96,7 @@ class AggregateNameLister:
async def __call__(self) -> Iterator[str]: async def __call__(self) -> Iterator[str]:
cfg = await Config.get() cfg = await Config.get()
return iter(cfg.calendar.aggregate.keys()) return iter(cfg.calendar.aggregates.keys())
@dataclass(frozen=True) @dataclass(frozen=True)

View file

@ -49,7 +49,7 @@ async def get_aggregate_calendar(
name: str = Depends(aggregate_unique), name: str = Depends(aggregate_unique),
) -> list[CalEvent]: ) -> list[CalEvent]:
cfg = await Config.get() cfg = await Config.get()
aggregate = cfg.calendar.aggregate[name] aggregate = cfg.calendar.aggregates[name]
calendars = ( calendars = (
DavCalendar(await calendar_unique(cal_prefix)) DavCalendar(await calendar_unique(cal_prefix))