Skip to content

Commit

Permalink
Enable to save configurations
Browse files Browse the repository at this point in the history
  • Loading branch information
kaizu committed Sep 4, 2020
1 parent 5de2c83 commit 253eb4c
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions scopyon/config.py
Expand Up @@ -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)
Expand Down

0 comments on commit 253eb4c

Please sign in to comment.