Example #1
0
    def _parse(paths, prepos, local_config, default_opts):
        """Parse files in paths to load config"""
        parser = SafeConfigParser(defaults=default_opts)

        recursive_paths = []
        for p in paths:
            if isinstance(p, basestring):
                recursive_paths.extend(_recursive_file_list(p))
            else:
                recursive_paths.append(p)

        read_configs(parser, recursive_paths)

        prepos['DEFAULT'] = RepoConfig("DEFAULT",
                                       parser.defaults(),
                                       local_config=local_config)

        for sname in parser.sections():
            optdict = {}
            for oname in parser.options(sname):
                optdict[oname] = parser.get(sname, oname)

            repo = RepoConfig(sname, optdict, local_config=local_config)
            for o in portage.sync.module_specific_options(repo):
                if parser.has_option(sname, o):
                    repo.set_module_specific_opt(o, parser.get(sname, o))

            # Perform repos.conf sync variable validation
            portage.sync.validate_config(repo, logging)

            # For backward compatibility with locations set via PORTDIR and
            # PORTDIR_OVERLAY, delay validation of the location and repo.name
            # until after PORTDIR and PORTDIR_OVERLAY have been processed.
            prepos[sname] = repo
Example #2
0
	def _parse(paths, prepos, local_config, default_opts):
		"""Parse files in paths to load config"""
		parser = SafeConfigParser(defaults=default_opts)

		recursive_paths = []
		for p in paths:
			if isinstance(p, basestring):
				recursive_paths.extend(_recursive_file_list(p))
			else:
				recursive_paths.append(p)

		read_configs(parser, recursive_paths)

		prepos['DEFAULT'] = RepoConfig("DEFAULT",
			parser.defaults(), local_config=local_config)

		for sname in parser.sections():
			optdict = {}
			for oname in parser.options(sname):
				optdict[oname] = parser.get(sname, oname)

			repo = RepoConfig(sname, optdict, local_config=local_config)
			for o in portage.sync.module_specific_options(repo):
				if parser.has_option(sname, o):
					repo.set_module_specific_opt(o, parser.get(sname, o))

			# Perform repos.conf sync variable validation
			portage.sync.validate_config(repo, logging)

			# For backward compatibility with locations set via PORTDIR and
			# PORTDIR_OVERLAY, delay validation of the location and repo.name
			# until after PORTDIR and PORTDIR_OVERLAY have been processed.
			prepos[sname] = repo
Example #3
0
def parse_desktop_entry(path):
    """
	Parse the given file with RawConfigParser and return the
	result. This may raise an IOError from io.open(), or a
	ParsingError from RawConfigParser.
	"""
    parser = RawConfigParser()

    read_configs(parser, [path])

    return parser
Example #4
0
def parse_desktop_entry(path):
	"""
	Parse the given file with RawConfigParser and return the
	result. This may raise an IOError from io.open(), or a
	ParsingError from RawConfigParser.
	"""
	parser = RawConfigParser()

	read_configs(parser, [path])

	return parser
Example #5
0
    def _parse(paths, defaults):
        parser = SafeConfigParser(defaults=defaults)
        recursive_paths = []
        for p in paths:
            if isinstance(p, str):
                recursive_paths.extend(_recursive_file_list(p))
            else:
                recursive_paths.append(p)

        read_configs(parser, recursive_paths)
        return parser
Example #6
0
    def __init__(self, paths, settings, trees):
        self._parser = SafeConfigParser(
            defaults={
                "EPREFIX": settings["EPREFIX"],
                "EROOT": settings["EROOT"],
                "PORTAGE_CONFIGROOT": settings["PORTAGE_CONFIGROOT"],
                "ROOT": settings["ROOT"],
            })

        if _ENABLE_SET_CONFIG:
            read_configs(self._parser, paths)
        else:
            self._create_default_config()

        self.errors = []
        self.psets = {}
        self.trees = trees
        self.settings = settings
        self._parsed = False
        self.active = []
Example #7
0
	def __init__(self, paths, settings, trees):
		self._parser = SafeConfigParser(
			defaults={
				"EPREFIX" : settings["EPREFIX"],
				"EROOT" : settings["EROOT"],
				"PORTAGE_CONFIGROOT" : settings["PORTAGE_CONFIGROOT"],
				"ROOT" : settings["ROOT"],
			})

		if _ENABLE_SET_CONFIG:
			read_configs(self._parser, paths)
		else:
			self._create_default_config()

		self.errors = []
		self.psets = {}
		self.trees = trees
		self.settings = settings
		self._parsed = False
		self.active = []
Example #8
0
#!/bin/env python3
import sys
import collections
from portage.util.configparser import (read_configs, SafeConfigParser)

p = SafeConfigParser({}, collections.defaultdict)
read_configs(p, sys.argv[1:])
first = True
for sect in sorted(p.sections()):
    if first:
        first = False
    else:
        print()
    print("[{}]".format(sect))
    for itm in sorted(p.items(sect)):
        print("{} = {}".format(itm[0], itm[1]))