ndeploy.py 文件源码

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

项目:ndeploy 作者: sglebs 项目源码 文件源码
def config_file_as_dict(**kwargs):
    cfgfile = kwargs["cfgfile"]
    cfgfile_contents = templated_file_contents(kwargs, kwargs["cfgfile"])
#    print (cfgfile_contents)
    cfg_data = {}
    if cfgfile.endswith(".json"):
        cfgdata = json.loads(cfgfile_contents)
    elif cfgfile.endswith(".toml"):
        cfgdata = toml.loads(cfgfile_contents)
    elif cfgfile.endswith(".yaml"):
        yaml.add_constructor('!join', join) # http://stackoverflow.com/questions/5484016/how-can-i-do-string-concatenation-or-string-replacement-in-yaml
        cfgdata = yaml.load(cfgfile_contents)
    else:
        raise ValueError("Invalid config file format")
    return merge_two_dicts(kwargs, cfgdata)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号