config.py 文件源码

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

项目:ave 作者: sonyxperiadev 项目源码 文件源码
def load(path):
    if not os.path.exists(path):
        user = ave.pwd.getpwuid_name(os.getuid())
        raise Exception(
            'no such configuration file: %s\n\nrun "ave-config --bootstrap=%s" '
            'to create one with default values' % (path, user)
        )

    config = None
    with open(path) as f:
        try:
            config = json.load(f)
        except Exception, e:
            raise Exception(
                'invalid config file %s: not valid JSON encoding: %s' % (path,e)
            )

    if type(config) != dict:
        raise Exception(
            'invalid config file %s: contents is not a dictionary: %s'
            % (path, type(config))
        )

    return config
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号