def save(self, cfg_file=None):
"""
Save's configuration back to disk.
"""
if cfg_file is None:
cfg_file = self.cfg_file
else:
# acquire new configuration path
cfg_file = abspath(expanduser(cfg_file))
try:
with open(cfg_file, 'w') as fp:
yaml.dump(self.cfg_data, fp, default_flow_style=False)
except IOError, e:
logger.debug('%s' % (str(e)))
logger.error('Failed to write configuration file %s' % (
cfg_file,
))
return False
# Update central configuration
self.cfg_file = cfg_file
if hasattr(self, '__mask_re'):
# Presumably something has changed if the user called save so we
# destroy our cached mask to be safe
del self.__mask_re
return True
评论列表
文章目录