config_util.py 文件源码

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

项目:artman 作者: googleapis 项目源码 文件源码
def load_config_spec(config_spec, config_sections, repl_vars, language):
    config_split = config_spec.strip().split(':')
    config_path = config_split[0]
    if len(config_split) > 1:
        config_sections = config_split[1].split('|')
    with open(config_path) as config_file:
        all_config_data = yaml.load(config_file, Loader=yaml.Loader)

    # Make a list of the appropriate configuration sections (just the ones
    # we are actually using) from the YAML file.
    segments = [all_config_data[i] for i in config_sections]
    segments.append(all_config_data.get(language, {}))

    # Merge all of the segments of data into a single config dictionary.
    config = merge(*segments)

    # Perform final replacements.
    return replace_vars(config, repl_vars)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号