aboutsummaryrefslogtreecommitdiffstats
path: root/fg21sim/configs
diff options
context:
space:
mode:
authorAaron LI <aaronly.me@outlook.com>2016-09-30 21:23:20 +0800
committerAaron LI <aaronly.me@outlook.com>2016-09-30 21:23:20 +0800
commit0b7cc2a9622d977b86c4cfc88b3e7888511d9848 (patch)
treea39f6480a7ecf47f39735959a70f199b6c76f7e7 /fg21sim/configs
parent47384df0765d05c3a497d9be85751257d4d04266 (diff)
downloadfg21sim-0b7cc2a9622d977b86c4cfc88b3e7888511d9848.tar.bz2
configs/manager.py: Make "validate()" method private.
Also unify the quote style.
Diffstat (limited to 'fg21sim/configs')
-rw-r--r--fg21sim/configs/manager.py16
1 files changed, 8 insertions, 8 deletions
diff --git a/fg21sim/configs/manager.py b/fg21sim/configs/manager.py
index a24475b..513878f 100644
--- a/fg21sim/configs/manager.py
+++ b/fg21sim/configs/manager.py
@@ -43,7 +43,7 @@ class ConfigManager:
list_values=False, _inspec=True)
configs_default = ConfigObj(interpolation=False,
configspec=self._configspec)
- self._config = self.validate(configs_default)
+ self._config = self._validate(configs_default)
if configs:
for config in configs:
self.read_config(config)
@@ -60,10 +60,10 @@ class ConfigManager:
"""
newconfig = ConfigObj(config, interpolation=False,
configspec=self._configspec)
- newconfig = self.validate(newconfig)
+ newconfig = self._validate(newconfig)
self._config.merge(newconfig)
- def validate(self, config):
+ def _validate(self, config):
"""Validate the config against the specification using a default
validator. The validated config values are returned if success,
otherwise, the ``ConfigError`` raised with details.
@@ -74,18 +74,18 @@ class ConfigManager:
except ConfigObjError as e:
raise ConfigError(e.message)
if not results:
- error_msg = ''
+ error_msg = ""
for (section_list, key, res) in flatten_errors(config, results):
if key is not None:
if res is False:
msg = 'key "%s" in section "%s" is missing.'
- msg = msg % (key, ', '.join(section_list))
+ msg = msg % (key, ", ".join(section_list))
else:
msg = 'key "%s" in section "%s" failed validation: %s'
- msg = msg % (key, ', '.join(section_list), res)
+ msg = msg % (key, ", ".join(section_list), res)
else:
- msg = 'section "%s" is missing' % '.'.join(section_list)
- error_msg += msg + '\n'
+ msg = 'section "%s" is missing' % ".".join(section_list)
+ error_msg += msg + "\n"
raise ConfigError(error_msg)
return config