Example #1
0
    def populate(self, parser, section, parent=None):
        """Set option values from an INI file section.

        :param parser: :class:`ConfigParser` instance (or subclass)
        :param section: INI file section to read use
        :param parent: Optional parent :class:`BaseConfig` (or
            subclass) instance to use when doing option value
            inheritance
        """
        self.cfg = parser
        self._section = section

        if parser.has_section(section):
            opts = set(parser.options(section))
        else:
            opts = set()
        for name in self.iterkeys():
            option = self.optionobj(name)
            value = None
            if name in opts:
                value = parser.get(section, name)
            else:
                # No matching option in this section, try inheriting
                if parent and option.inherit:
                    value = getattr(parent, name)

            if value is not None:
                setattr(self, name, value)
Example #2
0
    def populate(self, parser, section, parent=None):
        """Set option values from an INI file section.

        :param parser: :class:`ConfigParser` instance (or subclass)
        :param section: INI file section to read use
        :param parent: Optional parent :class:`BaseConfig` (or
            subclass) instance to use when doing option value
            inheritance
        """
        self.cfg = parser
        self._section = section

        if parser.has_section(section):
            opts = set(parser.options(section))
        else:
            opts = set()
        for name in self.iterkeys():
            option = self.optionobj(name)
            value = None
            if name in opts:
                value = parser.get(section, name)
            else:
                # No matching option in this section, try inheriting
                if parent and option.inherit:
                    value = getattr(parent, name)

            if value is not None:
                setattr(self, name, value)
Example #3
0
 def _populate(self, parser, section, priority=PRIO_DEFAULT):
     """Set option values from an INI file section."""
     if parser.has_section(section):
         for name in parser.options(section):
             value = parser.get(section, name)
             opt = self._get_option(name)
             if opt and not opt._is_runtimeonly():
                 opt._set(value, priority)
             else:
                 logger.warning(_('Unknown configuration option: %s = %s'),
                                ucd(name), ucd(value))
Example #4
0
 def _populate(self, parser, section, priority=PRIO_DEFAULT):
     """Set option values from an INI file section."""
     if parser.has_section(section):
         for name in parser.options(section):
             value = parser.get(section, name)
             opt = self._get_option(name)
             if opt and not opt._is_runtimeonly():
                 try:
                     opt._set(value, priority)
                 except dnf.exceptions.ConfigError as e:
                     logger.warning(
                         _('Unknown configuration value: '
                           '%s=%s; %s'), ucd(name), ucd(value), e.raw_error)
             else:
                 logger.warning(_('Unknown configuration option: %s = %s'),
                                ucd(name), ucd(value))
Example #5
0
File: config.py Project: edynox/dnf
 def _populate(self, parser, section, filename, priority=PRIO_DEFAULT):
     """Set option values from an INI file section."""
     if parser.has_section(section):
         for name in parser.options(section):
             value = parser.get(section, name)
             if not value or value == 'None':
                 value = None
             opt = self._get_option(name)
             if opt and not opt._is_runtimeonly():
                 try:
                     opt._set(value, priority)
                 except dnf.exceptions.ConfigError as e:
                     logger.debug(_('Unknown configuration value: '
                                    '%s=%s in %s; %s'), ucd(name),
                                  ucd(value), ucd(filename), e.raw_error)
             else:
                 logger.debug(
                     _('Unknown configuration option: %s = %s in %s'),
                     ucd(name), ucd(value), ucd(filename))