Ejemplo n.º 1
0
    def _explain(exception):
        """Explain parsing errors

        :param exception: Exception object
        :type exception: :class:`configobj.ConfigObjError`
        """
        message = u'\n'
        for error in exception.errors:
            message += error.message + '\n'

        raise configobj.ConfigObjError(message.rstrip('\n'))
Ejemplo n.º 2
0
    def __init__(self, conf_path):
        self._path = conf_path
        def_conf = configobj.ConfigObj(configspec=StringIO.StringIO(
            Config._def_conf),
                                       interpolation=False)

        try:
            def_conf.merge(configobj.ConfigObj(conf_path, interpolation=False))
        except configobj.ConfigObjError:
            raise

        validator = Validator()
        vres = def_conf.validate(validator, preserve_errors=True)

        for (section, key, error) in configobj.flatten_errors(def_conf, vres):

            if error:
                message = "%s/%s: %s" % ("/".join(section), key, error)
                raise configobj.ConfigObjError(message)

        self.conf = def_conf
        self.repos = def_conf['repos']

        self._cache = {'statuses': list()}