コード例 #1
0
    def _get_module_configs(self, module_path):
        """Parse and yield all module configs from a config file."""

        parser = dnf.conf.ConfigParser()
        try:
            confpp_obj = dnf.conf.parser.ConfigPreProcessor(module_path)
            parser.readfp(confpp_obj)
        except dnf.conf.ParsingError as e:
            msg = str(e)
            raise dnf.exceptions.ConfigError(msg)

        # Check sections in the .module file that was just slurped up
        for section in parser.sections():

            if section == 'main':
                continue

            try:
                module = self._build_module(parser, section, module_path)
            except (dnf.exceptions.RepoError, dnf.exceptions.ConfigError) as e:
                logger.warning(e)
                continue
            else:
                module.config_file = module_path

            yield module
コード例 #2
0
ファイル: main.py プロジェクト: kudlav/dnf
    def _load(self, filename):
        parser = iniparse.compat.ConfigParser()
        config_pp = dnf.conf.parser.ConfigPreProcessor(filename)
        try:
            parser.readfp(config_pp)
        except iniparse.compat.ParsingError as e:
            raise dnf.exceptions.ConfigError("Parsing file failed: %s" % e)

        self.commands.populate(parser, 'commands')
        self.email.populate(parser, 'email')
        self.emitters.populate(parser, 'emitters')
        self._parser = parser
コード例 #3
0
ファイル: main.py プロジェクト: IMFTC/dnf
    def _load(self, filename):
        parser = iniparse.compat.ConfigParser()
        config_pp = dnf.conf.parser.ConfigPreProcessor(filename)
        try:
            parser.readfp(config_pp)
        except iniparse.compat.ParsingError as e:
            raise dnf.exceptions.ConfigError("Parsing file failed: %s" % e)

        self.commands.populate(parser, 'commands')
        self.email.populate(parser, 'email')
        self.emitters.populate(parser, 'emitters')
        self._parser = parser
コード例 #4
0
ファイル: main.py プロジェクト: pnemade/dnf
    def _load(self, filename):
        parser = iniparse.compat.ConfigParser()
        config_pp = dnf.conf.parser.ConfigPreProcessor(filename)
        try:
            parser.readfp(config_pp)
        except iniparse.compat.ParsingError as e:
            raise dnf.exceptions.ConfigError("Parsing file failed: %s" % e)

        self.commands._populate(parser, "commands", dnf.conf.PRIO_AUTOMATICCONFIG)
        self.email._populate(parser, "email", dnf.conf.PRIO_AUTOMATICCONFIG)
        self.emitters._populate(parser, "emitters", dnf.conf.PRIO_AUTOMATICCONFIG)
        self._parser = parser
コード例 #5
0
ファイル: config.py プロジェクト: haghabozorgi/dnf
    def read(self, filename=None):
        # :api
        if filename is None:
            filename = self.config_file_path
        parser = ConfigParser()
        config_pp = dnf.conf.parser.ConfigPreProcessor(filename)
        try:
            parser.readfp(config_pp)
        except ParsingError as e:
            raise dnf.exceptions.ConfigError("Parsing file failed: %s" % e)
        self.populate(parser, 'main')

        # update to where we read the file from
        self.config_file_path = filename
コード例 #6
0
    def read(self, filename=None):
        # :api
        if filename is None:
            filename = self.config_file_path
        parser = ConfigParser()
        config_pp = dnf.conf.parser.ConfigPreProcessor(filename)
        try:
            parser.readfp(config_pp)
        except ParsingError as e:
            raise dnf.exceptions.ConfigError("Parsing file failed: %s" % e)
        self.populate(parser, 'main')

        # update to where we read the file from
        self.config_file_path = filename
コード例 #7
0
ファイル: read.py プロジェクト: yavor-atanasov/dnf
    def _get_repos(self, repofn):
        """Parse and yield all repositories from a config file."""

        substs = self.conf.substitutions
        parser = dnf.yum.config.ConfigParser()
        try:
            confpp_obj = dnf.conf.parser.ConfigPreProcessor(repofn,
                                                            vars=substs)

            parser.readfp(confpp_obj)
        except dnf.yum.config.ParsingError as e:
            msg = str(e)
            raise dnf.exceptions.ConfigError(msg)

        # Check sections in the .repo file that was just slurped up
        for section in parser.sections():

            if section == 'main':
                continue

            # Check the repo.id against the valid chars
            invalid = dnf.repo.repo_id_invalid(section)
            if invalid is not None:
                logger.warning("Bad id for repo: %s, byte = %s %d", section,
                               section[invalid], invalid)
                continue

            try:
                thisrepo = self._build_repo(parser, section)
            except (dnf.exceptions.RepoError, dnf.exceptions.ConfigError) as e:
                logger.warning(e)
                continue
            else:
                thisrepo.repofile = repofn

            if thisrepo.id in self.repo_setopts:
                for opt in self.repo_setopts[thisrepo.id].items:
                    if not hasattr(thisrepo, opt):
                        msg = "Repo %s did not have a %s attr. before setopt"
                        logger.warning(msg, thisrepo.id, opt)
                    setattr(thisrepo, opt,
                            getattr(self.repo_setopts[thisrepo.id], opt))

            yield thisrepo
コード例 #8
0
ファイル: read.py プロジェクト: Aftermath/dnf
    def _get_repos(self, repofn):
        """Parse and yield all repositories from a config file."""

        substs = self.conf.substitutions
        parser = dnf.yum.config.ConfigParser()
        try:
            confpp_obj = dnf.conf.parser.ConfigPreProcessor(repofn, vars=substs)

            parser.readfp(confpp_obj)
        except dnf.yum.config.ParsingError as e:
            msg = str(e)
            raise dnf.exceptions.ConfigError(msg)

        # Check sections in the .repo file that was just slurped up
        for section in parser.sections():

            if section == 'main':
                continue

            # Check the repo.id against the valid chars
            invalid = dnf.repo.repo_id_invalid(section)
            if invalid is not None:
                logger.warning("Bad id for repo: %s, byte = %s %d", section,
                               section[invalid], invalid)
                continue

            try:
                thisrepo = self._build_repo(parser, section)
            except (dnf.exceptions.RepoError, dnf.exceptions.ConfigError) as e:
                logger.warning(e)
                continue
            else:
                thisrepo.repofile = repofn

            if thisrepo.id in self.repo_setopts:
                for opt in self.repo_setopts[thisrepo.id].items:
                    if not hasattr(thisrepo, opt):
                        msg = "Repo %s did not have a %s attr. before setopt"
                        logger.warning(msg, thisrepo.id, opt)
                    setattr(thisrepo, opt, getattr(self.repo_setopts[thisrepo.id],
                                                   opt))

            yield thisrepo
コード例 #9
0
ファイル: read.py プロジェクト: hanzz/dnf
    def _get_repos(self, repofn):
        """Parse and yield all repositories from a config file."""

        substs = self.conf.substitutions
        parser = dnf.conf.ConfigParser()
        try:
            confpp_obj = dnf.conf.parser.ConfigPreProcessor(repofn,
                                                            variables=substs)

            parser.readfp(confpp_obj)
        except dnf.conf.ParsingError as e:
            msg = str(e)
            raise dnf.exceptions.ConfigError(msg)

        # Check sections in the .repo file that was just slurped up
        for section in parser.sections():

            if section == 'main':
                continue

            # Check the repo.id against the valid chars
            invalid = dnf.repo.repo_id_invalid(section)
            if invalid is not None:
                logger.warning("Bad id for repo: %s, byte = %s %d", section,
                               section[invalid], invalid)
                continue

            try:
                thisrepo = self._build_repo(parser, section)
            except (dnf.exceptions.RepoError, dnf.exceptions.ConfigError) as e:
                logger.warning(e)
                continue
            else:
                thisrepo.repofile = repofn

            thisrepo._configure_from_options(self.opts)

            yield thisrepo
コード例 #10
0
ファイル: read.py プロジェクト: spathare21/dnf
    def _get_repos(self, repofn):
        """Parse and yield all repositories from a config file."""

        substs = self.conf.substitutions
        parser = dnf.conf.ConfigParser()
        try:
            confpp_obj = dnf.conf.parser.ConfigPreProcessor(repofn,
                                                            variables=substs)

            parser.readfp(confpp_obj)
        except dnf.conf.ParsingError as e:
            msg = str(e)
            raise dnf.exceptions.ConfigError(msg)

        # Check sections in the .repo file that was just slurped up
        for section in parser.sections():

            if section == 'main':
                continue

            # Check the repo.id against the valid chars
            invalid = dnf.repo.repo_id_invalid(section)
            if invalid is not None:
                logger.warning("Bad id for repo: %s, byte = %s %d", section,
                               section[invalid], invalid)
                continue

            try:
                thisrepo = self._build_repo(parser, section, repofn)
            except (dnf.exceptions.RepoError, dnf.exceptions.ConfigError) as e:
                logger.warning(e)
                continue
            else:
                thisrepo.repofile = repofn

            thisrepo._configure_from_options(self.opts)

            yield thisrepo