config.py 文件源码

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

项目:aniping 作者: kuruoujou 项目源码 文件源码
def from_yaml(self, config_file):
        """Yaml config getter function.

        Reads a yaml flask config file and generates a config
        dictionary out of it that flask and aniping can 
        both understand.

        Args:
            config_file (str): the path of the config file to load.
                               Can be relative or absolute.
        """
        env = os.environ.get('FLASK_ENV', 'development')
        self['ENVIRONMENT'] = env.lower()

        with open(config_file) as f:
            config = yaml.safe_load(f)

        config = config.get(env.upper(), config)

        for key in config.keys():
            if key.isupper():
                self[key] = config[key]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号