Add write method to ConfigLoader
@@ -46,6 +46,14 @@ def load(path: str):
return ConfigLoader.load_json(path)
raise RuntimeError(f'Unknown file type: {path}')
+ @staticmethod
+ def write(path: str, config):
+ if path.endswith('.yml'):
+ return ConfigLoader.write_yaml(path, config)
+ if path.endswith('.json'):
+ return ConfigLoader.write_json(path, config)
+ raise RuntimeError(f'Unknown file type: {path}')
+
@staticmethod
def load_json(path: str):
with open(path, "r", encoding="utf-8") as fp:
