sanic/guide/webapp/worker/config.py

16 lines
397 B
Python
Raw Permalink Normal View History

from pathlib import Path
from msgspec import yaml
2023-10-25 01:03:35 +01:00
from webapp.display.layouts.models import GeneralConfig, MenuItem
def load_menu(path: Path) -> list[MenuItem]:
loaded = yaml.decode(path.read_bytes(), type=dict[str, list[MenuItem]])
return loaded["root"]
def load_config(path: Path) -> GeneralConfig:
loaded = yaml.decode(path.read_bytes(), type=GeneralConfig)
return loaded