config.py 文件源码

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

项目:kaira 作者: mulonemartin 项目源码 文件源码
def from_pyfile(self, filename):
        """Update the values in the config from a Python file.
        Only the uppercase variables in that module are stored in the config.
        :param filename: an absolute path to the config file
        """
        module = types.ModuleType('config')
        module.__file__ = filename
        try:
            with open(filename) as config_file:
                exec(compile(config_file.read(), filename, 'exec'),
                     module.__dict__)
        except IOError as e:
            e.strerror = 'Unable to load configuration file (%s)' % e.strerror
            raise
        self.from_object(module)
        return True
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号