__init__.py 文件源码

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

项目:cligraphy 作者: Netflix-Skunkworks 项目源码 文件源码
def read_configuration(cligraph, custom_suffix=''):
    """Read configuration dict for the given tool
    """

    cfg = {}
    layers = collections.OrderedDict()
    layers['auto'] = [automatic_configuration, None]
    layers['shared'] = [os.path.join(cligraph.tool_path, 'conf/%s.yaml' % cligraph.tool_shortname), None]
    layers['custom'] = [os.path.join(os.path.abspath(os.path.expanduser('~/.' + cligraph.tool_shortname)), '%s.yaml%s' % (cligraph.tool_shortname, custom_suffix)), None]

    for layer_name, layer_data in layers.items():
        if callable(layer_data[0]):
            layer = layer_data[0](cligraph, layer_name)
        else:
            if not os.path.exists(layer_data[0]):
                continue
            with open(layer_data[0], 'r') as filep:
                layer = yaml.load(filep, Loader=Loader)
        layers[layer_name][1] = layer
        if layer:
            update_recursive(cfg, layer)

    resolve_config(cfg)
    return AttrDict(**cfg), layers
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号