mirror of
https://framagit.org/framasoft/framaspace/argos.git
synced 2025-04-28 09:52:38 +02:00
22 lines
573 B
Python
22 lines
573 B
Python
"""Pydantic schemas for server"""
|
|
from pathlib import Path
|
|
|
|
import yaml
|
|
from yamlinclude import YamlIncludeConstructor
|
|
|
|
from argos_monitoring.schemas.config import Config
|
|
|
|
|
|
def read_yaml_config(filename):
|
|
parsed = _load_yaml(filename)
|
|
return Config(**parsed)
|
|
|
|
|
|
def _load_yaml(filename):
|
|
base_dir = Path(filename).resolve().parent
|
|
YamlIncludeConstructor.add_to_loader_class(
|
|
loader_class=yaml.FullLoader, base_dir=str(base_dir)
|
|
)
|
|
|
|
with open(filename, "r", encoding="utf-8") as stream:
|
|
return yaml.load(stream, Loader=yaml.FullLoader)
|