From ac8f33b03846cf607ca19e7a83e5da80730bde9f Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Thu, 29 Sep 2016 13:02:40 +0800 Subject: configs: Fix ConfigError and disable interpolation Since we do not use string interpolation in configs, so disable this feature, otherwise `MissingInterpolationOption` error happens due to the "logging" configs which contains string formats. --- fg21sim/configs/manager.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'fg21sim') diff --git a/fg21sim/configs/manager.py b/fg21sim/configs/manager.py index 2fee986..fe85390 100644 --- a/fg21sim/configs/manager.py +++ b/fg21sim/configs/manager.py @@ -12,13 +12,17 @@ Configuration manager. import os import sys from glob import glob -from errors import ConfigError import logging from configobj import ConfigObj, ConfigObjError, flatten_errors from validate import Validator +class ConfigError(Exception): + """Could not parse user configurations""" + pass + + CONFIGS_PATH = os.path.dirname(__file__) @@ -32,14 +36,16 @@ class ConfigManager: spec = "\n".join([open(f).read() for f in configs_spec]).split("\n") self._configspec = ConfigObj(spec, interpolation=False, list_values=False, _inspec=True) - configs_default = ConfigObj(configspec=self._configspec) + configs_default = ConfigObj(interpolation=False, + configspec=self._configspec) self._config = self.validate(configs_default) if configs: for config in configs: self.read_config(config) def read_config(self, config): - newconfig = ConfigObj(config, configspec=self._configspec) + newconfig = ConfigObj(config, interpolation=False, + configspec=self._configspec) newconfig = self.validate(newconfig) self._config.merge(newconfig) -- cgit v1.2.2