| 13 | |
| 14 | |
| 15 | class YAMLFileProxy: |
| 16 | def __init__(self, file_name: Path): |
| 17 | self.file_path = file_name |
| 18 | |
| 19 | # Transparent Config Cache |
| 20 | if not self.file_path.exists(): |
| 21 | self.__file_cache = SimpleNamespace() |
| 22 | else: |
| 23 | self.__file_cache, _ = load_config(self.file_path) |
| 24 | |
| 25 | @property |
| 26 | def data(self) -> SimpleNamespace: |
| 27 | return self.__file_cache |
| 28 | |
| 29 | @data.setter |
| 30 | def data(self, value): |
| 31 | self.__file_cache = value |
| 32 | with open(self.file_path, "w") as file: |
| 33 | yaml.safe_dump(self.__file_cache, file) |
| 34 | |
| 35 | |
| 36 | class SandboxFile: |