config.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:virt-backup 作者: Anthony25 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号