sanic/guide/webapp/worker/config.py
2023-09-06 15:44:00 +03:00

15 lines
396 B
Python

from pathlib import Path
from msgspec import yaml
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