コード例 #1
0
def parse_config(config_files):
    # search a couple of different areas for the main config file
    myconf = {}

    # try and parse the config file "config_file"
    for config_file in config_files:
        log.notice('Loading configuration file: %s', config_file)
        try:
            config = catalyst.config.ConfigParser(config_file)
            myconf.update(config.get_values())
        except Exception as e:
            log.critical('Could not find parse configuration file: %s: %s',
                         config_file, e)

    # now, load up the values into conf_values so that we can use them
    for x in list(confdefaults):
        if x in myconf:
            if x == 'options':
                conf_values[x] = set(myconf[x].split())
            elif x in ["decompressor_search_order"]:
                conf_values[x] = myconf[x].split()
            else:
                conf_values[x] = myconf[x]
        else:
            conf_values[x] = confdefaults[x]

    # add our python base directory to use for loading target arch's
    conf_values["PythonDir"] = os.path.dirname(os.path.realpath(__file__))

    # print out any options messages
    for opt in conf_values['options']:
        if opt in option_messages:
            log.info(option_messages[opt])

    for key in [
            "digests", "envscript", "var_tmpfs_portage", "port_logdir",
            "local_overlay"
    ]:
        if key in myconf:
            conf_values[key] = myconf[key]

    if "contents" in myconf:
        # replace '-' with '_' (for compatibility with existing configs)
        conf_values["contents"] = myconf["contents"].replace("-", '_')

    if "envscript" in myconf:
        log.info('Envscript support enabled.')

    # take care of any variable substitutions that may be left
    for x in list(conf_values):
        if isinstance(conf_values[x], str):
            conf_values[x] = conf_values[x] % conf_values
コード例 #2
0
ファイル: main.py プロジェクト: linux-on-power/catalyst
def parse_config(config_files):
	# search a couple of different areas for the main config file
	myconf={}

	# try and parse the config file "config_file"
	for config_file in config_files:
		log.notice('Loading configuration file: %s', config_file)
		try:
			config = catalyst.config.ConfigParser(config_file)
			myconf.update(config.get_values())
		except Exception as e:
			log.critical('Could not find parse configuration file: %s: %s',
				config_file, e)

	# now, load up the values into conf_values so that we can use them
	for x in list(confdefaults):
		if x in myconf:
			if x == 'options':
				conf_values[x] = set(myconf[x].split())
			elif x in ["decompressor_search_order"]:
				conf_values[x] = myconf[x].split()
			else:
				conf_values[x]=myconf[x]
		else:
			conf_values[x]=confdefaults[x]

	# add our python base directory to use for loading target arch's
	conf_values["PythonDir"] = __selfpath__

	# print out any options messages
	for opt in conf_values['options']:
		if opt in option_messages:
			log.info(option_messages[opt])

	for key in ["digests", "envscript", "var_tmpfs_portage", "port_logdir",
				"local_overlay"]:
		if key in myconf:
			conf_values[key] = myconf[key]

	if "contents" in myconf:
		# replace '-' with '_' (for compatibility with existing configs)
		conf_values["contents"] = myconf["contents"].replace("-", '_')

	if "envscript" in myconf:
		log.info('Envscript support enabled.')

	# take care of any variable substitutions that may be left
	for x in list(conf_values):
		if isinstance(conf_values[x], str):
			conf_values[x] = conf_values[x] % conf_values