aboutsummaryrefslogtreecommitdiffstats
path: root/fg21sim/configs/manager.py
diff options
context:
space:
mode:
authorAaron LI <aaronly.me@outlook.com>2016-09-29 13:02:40 +0800
committerAaron LI <aaronly.me@outlook.com>2016-09-29 13:02:40 +0800
commitac8f33b03846cf607ca19e7a83e5da80730bde9f (patch)
tree03683a42f93a67675e73a5f927dfab7f9d94800e /fg21sim/configs/manager.py
parentb73d8b844a33f517d30cbced35d49f8140425e93 (diff)
downloadfg21sim-ac8f33b03846cf607ca19e7a83e5da80730bde9f.tar.bz2
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.
Diffstat (limited to 'fg21sim/configs/manager.py')
-rw-r--r--fg21sim/configs/manager.py12
1 files changed, 9 insertions, 3 deletions
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)