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)
评论列表
文章目录