mirror of
https://code.lenaisten.de/Lenaisten/advent22.git
synced 2024-11-27 01:43:08 +00:00
54 lines
968 B
Python
54 lines
968 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_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))
|