From 0b7cc2a9622d977b86c4cfc88b3e7888511d9848 Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Fri, 30 Sep 2016 21:23:20 +0800 Subject: configs/manager.py: Make "validate()" method private. Also unify the quote style. --- fg21sim/configs/manager.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'fg21sim') 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 -- cgit v1.2.2