mirror of
https://code.lenaisten.de/Lenaisten/advent22.git
synced 2024-12-26 22:23:02 +00:00
54 lines
970 B
Python
54 lines
970 B
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
|
|
|
|
# Monat, während dem der Kalender läuft
|
|
# TODO penner
|
|
month: int = 12
|
|
|
|
# Alle Türen bleiben noch so viele Monate offen
|
|
# TODO penner
|
|
keep_open: int = 3
|
|
|
|
|
|
class Puzzle(BaseModel):
|
|
# Lösungswort
|
|
solution: str
|
|
|
|
# Länge des Kalenders
|
|
# TODO penner
|
|
days: int = 24
|
|
|
|
# Kalenderdefinition
|
|
calendar: str = "default.toml"
|
|
|
|
# Serverseitiger zusätzlicher "random" seed
|
|
random_pepper: 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))
|