diff --git a/overviewer_core/configParser.py b/overviewer_core/configParser.py index ee47d01..78b5f84 100644 --- a/overviewer_core/configParser.py +++ b/overviewer_core/configParser.py @@ -68,7 +68,7 @@ class MultiWorldParser(object): """Validate and return the configuration""" # Okay, this is okay, isn't it? We're going to create the validation # routine right here, right now. I hope this works! - validator = settingsValidators.make_configDictValidator(self._settings) + validator = settingsValidators.make_configDictValidator(self._settings, ignore_undefined=True) # Woah. What just happened? No. WAIT, WHAT ARE YOU... validated_config = validator(self._config_state) # WHAT HAVE YOU DONE? diff --git a/overviewer_core/settingsValidators.py b/overviewer_core/settingsValidators.py index 126c634..3426919 100644 --- a/overviewer_core/settingsValidators.py +++ b/overviewer_core/settingsValidators.py @@ -148,7 +148,7 @@ def make_dictValidator(keyvalidator, valuevalidator): return newd return v -def make_configDictValidator(config): +def make_configDictValidator(config, ignore_undefined=False): """Okay, stay with me here, this may get confusing. This function returns a validator that validates a "configdict". This is a term I just made up to refer to a dict that holds config information: keys are strings and values @@ -160,6 +160,10 @@ def make_configDictValidator(config): I hope that makes sense. + ignore_undefined, if True, will ignore any items in the dict to be + validated which don't have a corresponding definition in the config. + Otherwise, undefined entries will raise an error. + """ def configDictValidator(d): newdict = {} @@ -177,9 +181,10 @@ def make_configDictValidator(config): # Now that all the defined keys have been accounted for, check to make # sure any unauthorized keys were not specified. - for key in d.iterkeys(): - if key not in config: - raise ValidationException("'%s' is not a configuration item" % key) + if not ignore_undefined: + for key in d.iterkeys(): + if key not in config: + raise ValidationException("'%s' is not a configuration item" % key) return newdict return configDictValidator