added yaml deserializer and move all yamll stuff to one folder

This commit is contained in:
Ari Sosnovsky committed 2021-11-11 11:51:58 -05:00
1 parent a05c1b9dca
commit 2768975f9d
12 files changed
+114 -37

No files matched your search

+19
View File
@@ -0,0 +1,19 @@
import io
from pathlib import Path
from typing import Any, List
from src.yaml_serializer.base_yaml import yaml
from src.yaml_serializer.HassSafeConstructor import HassYaml
from src.yaml_serializer.types import HassConfig, SecretValue, IncludedYaml
def load_hass_config(file_path: Path) -> HassConfig:
HAY = HassYaml()
data = HAY.load(file_path / "configuration.yaml")
return HassConfig(HAY.secrets, data)
def dump_yaml(obj: Any) -> str:
stream = io.StringIO()
yaml.dump(obj, stream)
stream.seek(0)
return stream.read()