24 lines
569 B
Python
24 lines
569 B
Python
from pathlib import Path
|
|
|
|
import yaml
|
|
from pydantic import BaseModel
|
|
|
|
|
|
class MasterHLANames(BaseModel):
|
|
hla_apps: list[str]
|
|
|
|
@classmethod
|
|
def read_from_file(cls, path: Path) -> "MasterHLANames":
|
|
with open(path) as f:
|
|
d = yaml.safe_load(f)
|
|
|
|
hla_names = MasterHLANames.model_validate(d)
|
|
return hla_names
|
|
|
|
def add_hla_name(self, name: str):
|
|
self.hla_apps.append(name)
|
|
|
|
def write_to_file(self, path: Path) -> None:
|
|
with open(path, "w") as f:
|
|
yaml.safe_dump(self.model_dump(), f, indent=4)
|