Exemplo n.º 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
Exemplo n.º 2
0
    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
Exemplo n.º 3
0
    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
Exemplo n.º 4
0
Arquivo: read.py Projeto: 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
Exemplo n.º 5
0
    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