(self, key)
Unset a value in the configuration.
Unset a value in the configuration.
Unset a value in the configuration .
def unset_value(self, key):
        # type: (str) -> None
        """Unset a value in the configuration.
        """
        self._ensure_have_load_only()

        if key not in self._config[self.load_only]:
            raise ConfigurationError("No such key - {}".format(key))

        fname, parser = self._get_parser_to_modify()

        if parser is not None:
            section, name = _disassemble_key(key)

            # Remove the key in the parser
            modified_something = False
            if parser.has_section(section):
                # Returns whether the option was removed or not
                modified_something = parser.remove_option(section, name)

            if modified_something:
                # name removed from parser, section may now be empty
                section_iter = iter(parser.items(section))
                try:
                    val = next(section_iter)
                except StopIteration:
                    val = None

                if val is None:
                    parser.remove_section(section)

                self._mark_as_modified(fname, parser)
            else:
                raise ConfigurationError(
                    "Fatal Internal error [id=1]. Please report as a bug."
                )

        del self._config[self.load_only][key]
def unset_value ( self , key ) : # type: (str) -> None self . _ensure_have_load_only ( ) if key not in self . _config [ self . load_only ] : raise ConfigurationError ( "No such key - {}" . format ( key ) ) fname , parser = self . _get_parser_to_modify ( ) if parser is not None : section , name = _disassemble_key ( key ) # Remove the key in the parser modified_something = False if parser . has_section ( section ) : # Returns whether the option was removed or not modified_something = parser . remove_option ( section , name ) if modified_something : # name removed from parser, section may now be empty section_iter = iter ( parser . items ( section ) ) try : val = next ( section_iter ) except StopIteration : val = None if val is None : parser . remove_section ( section ) self . _mark_as_modified ( fname , parser ) else : raise ConfigurationError ( "Fatal Internal error [id=1]. Please report as a bug." ) del self . _config [ self . load_only ] [ key ]