Error if unknown sections are in the config.

This commit is contained in:
Florian Bruhin 2014-09-12 17:53:27 +02:00
parent a796482c83
commit ab0e600977
2 changed files with 14 additions and 1 deletions

View File

@ -176,6 +176,8 @@ class Application(QApplication):
self)
except (configtypes.ValidationError,
config.NoOptionError,
config.NoSectionError,
config.UnknownSectionError,
config.InterpolationSyntaxError,
configparser.InterpolationError,
configparser.DuplicateSectionError,

View File

@ -75,6 +75,13 @@ class InterpolationSyntaxError(ValueError):
pass
class UnknownSectionError(Exception):
"""Exception raised when there was an unknwon section in the config."""
pass
class ConfigManager(QObject):
"""Configuration manager for qutebrowser.
@ -203,7 +210,11 @@ class ConfigManager(QObject):
Args:
cp: The configparser instance to read the values from.
"""
for sectname in self.sections.keys():
for sectname in cp:
if sectname is not 'DEFAULT' and sectname not in self.sections:
raise UnknownSectionError("Unknown section '{}'!".format(
sectname))
for sectname in self.sections:
if sectname not in cp:
continue
for k, v in cp[sectname].items():