61 lines
1 KiB
Python
61 lines
1 KiB
Python
import tomllib
|
|
|
|
from pydantic import BaseModel
|
|
|
|
from .settings import SETTINGS
|
|
from .webdav import WebDAV
|
|
|
|
|
|
class User(BaseModel):
|
|
name: str
|
|
password: str
|
|
|
|
|
|
class Server(BaseModel):
|
|
# Dateiname Schriftart
|
|
font: str
|
|
|
|
# Tag, an dem der Kalender startet
|
|
# TODO penner
|
|
first_day: int = 1
|
|
|
|
# Monat, in dem der Kalender startet
|
|
# TODO penner
|
|
month: int = 12
|
|
|
|
# Alle Türen bleiben noch so viele Tage offen
|
|
# TODO penner
|
|
keep_open: int = 90
|
|
|
|
|
|
class Puzzle(BaseModel):
|
|
# Titel
|
|
title: str
|
|
|
|
# Lösungswort
|
|
solution: str
|
|
|
|
# Länge des Kalenders
|
|
# TODO penner
|
|
days: int = 24
|
|
|
|
# Kalenderdefinition
|
|
calendar: str = "default.toml"
|
|
|
|
# Serverseitiger zusätzlicher "random" seed
|
|
random_seed: str = ""
|
|
|
|
|
|
class Config(BaseModel):
|
|
admin: User
|
|
server: Server
|
|
puzzle: Puzzle
|
|
|
|
|
|
async def get_config() -> Config:
|
|
"""
|
|
Globale Konfiguration lesen
|
|
"""
|
|
|
|
txt = await WebDAV.read_str(path=SETTINGS.webdav.config_filename)
|
|
return Config.model_validate(tomllib.loads(txt))
|