def from_yaml(self, filename, silent=False):
"""
Updates the values in the config from a yaml file.
:param filename: filename of the config.
:param silent: set to ``True`` if you want silent failure for missing
files.
"""
filename = os.path.join(filename)
try:
with open(filename) as conf_yaml:
self.from_dict(yaml.safe_load(conf_yaml))
except IOError as e:
if silent and e.errno in (errno.ENOENT, errno.EISDIR):
return False
e.strerror = 'Unable to load configuration file (%s)' % e.strerror
raise
return True
评论列表
文章目录