2024-05-25 20:18:40 +00:00
|
|
|
from pydantic import RootModel
|
|
|
|
|
2024-05-27 13:10:24 +00:00
|
|
|
from taleweave.utils.file import load_yaml, save_yaml
|
2024-05-25 20:18:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
def load_system_data(cls, file):
|
2024-05-26 20:59:12 +00:00
|
|
|
with open(file, "r") as f:
|
|
|
|
data = load_yaml(f)
|
|
|
|
|
|
|
|
return cls(**data)
|
2024-05-25 20:18:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
def save_system_data(cls, file, model):
|
|
|
|
data = RootModel[cls](model).model_dump()
|
|
|
|
with open(file, "w") as f:
|
|
|
|
save_yaml(f, data)
|