Function save_config
Synopsis
def save_config(config, path, save_readable=True)
Description
Serialize and saves the config. If save_readable is True, a path.txt is also created
Source
Lines 72-89 in anyfig/figutils.py.
def save_config(config, path, save_readable=True):
''' Serialize and saves the config. If save_readable is True, a *path*.txt is also created '''
path = Path(path)
err_msg = f"Can only save anyfig config objects, not {type(config)}"
assert is_config_class(config), err_msg
with open(path, 'wb') as f:
dill.dump(config, f, dill.HIGHEST_PROTOCOL)
if save_readable:
source_codes = list(_get_source(config).values())
with open(path.with_suffix('.txt'), 'w') as f:
f.write(str(config))
f.write('\n\n\n')
f.write('\n'.join(source_codes))
return config