Exemple #1
0
 def _get(self, section, option):
     """Like .get, but returns the real section name and the value."""
     name, data = self._get_section(section)
     if data is None:
         raise configparser.NoSectionError(section)
     try:
         return name, data[option]
     except KeyError:
         raise configparser.NoOptionError(option, name)
Exemple #2
0
    def get(self, section, option, *args, **kwargs):
        """Get a value, replacing environment variables also.

        The arguments are the same as `RawConfigParser.get`, but in the found
        value, ``$WORD`` or ``${WORD}`` are replaced by the value of the
        environment variable ``WORD``.

        Returns the finished value.

        """
        for section_prefix in self.section_prefixes:
            real_section = section_prefix + section
            if configparser.RawConfigParser.has_option(self, real_section,
                                                       option):
                break
        else:
            raise configparser.NoOptionError(option, section)

        v = configparser.RawConfigParser.get(self, real_section, option, *args,
                                             **kwargs)
        v = substitute_variables(v, os.environ)
        return v