diff --git a/scopyon/config.py b/scopyon/config.py index c3f9554..5f94859 100644 --- a/scopyon/config.py +++ b/scopyon/config.py @@ -52,6 +52,17 @@ def __repr__(self): from yaml import Dumper return yaml.dump(self.__yaml, default_flow_style=False, Dumper=Dumper) + def save(self, file): + """ Save configurations as YAML file. + + Args: + file (str): An output file name. + """ + assert isinstance(file, (str, pathlib.PurePath)) + file = file if isinstance(file, str) else str(file) + with open(file, 'w') as f: + f.write(repr(self)) + def update(self, conf): if isinstance(conf, Configuration): dict_merge(self.__yaml, conf.yaml)