config.py 文件源码

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

项目:pyomo 作者: Pyomo 项目源码 文件源码
def __init__(self):
        self._options_stack = [ default_pyomo_config() ]

        # Load the user's configuration
        sources = [(json.load, 'json')]
        if yaml_available:
            sources.append( (yaml.load, 'yml') )
            sources.append( (yaml.load, 'yaml') )
        for parser, suffix in sources:
            cfg_file = os.path.join( appdirs.user_data_dir('pyomo'),
                                     'config.'+suffix)
            if os.path.exists(cfg_file):
                fp = open(cfg_file)
                try:
                    data = parser(fp)
                except:
                    logger.error("Error parsing the user's default "
                                 "configuration file\n\t%s." % (cfg_file,))
                self._options_stack[0].set_value(data)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号