Skip to content
Snippets Groups Projects
Commit 5618041d authored by Karl-Hermann Wieners's avatar Karl-Hermann Wieners
Browse files

Config: changed to allow values with native variables to be interpolated correctly

parent 52da3610
No related branches found
No related tags found
No related merge requests found
...@@ -14,6 +14,11 @@ Global ...@@ -14,6 +14,11 @@ Global
* Changed directory creation to only create parts w/o native variables * Changed directory creation to only create parts w/o native variables
Configuration
-------------
* Changed to allow values with native variables to be interpolated correctly
Release 1.0.9 Release 1.0.9
============= =============
......
...@@ -261,7 +261,23 @@ class ExpConfig(ConfigObj): ...@@ -261,7 +261,23 @@ class ExpConfig(ConfigObj):
if isinstance(value, (list, tuple)): if isinstance(value, (list, tuple)):
value = map(eval_expression, value) value = map(eval_expression, value)
elif isinstance(value, basestring): elif isinstance(value, basestring):
value = eval_expression(value) value = eval_expression(value)
if isinstance(value, (list, tuple)):
value = [v.replace('$', '$$') for v in value]
elif isinstance(value, basestring):
value = value.replace('$', '$$')
except (InterpolationError, ValueError) as error:
raise ExpConfigError(error.message, key)
section[key] = value
# Undo remaining changes from walk with eval_key
def uneval_key(section, key):
try:
value = section[key]
if isinstance(value, (list, tuple)):
value = [v.replace('$$', '$') for v in value]
elif isinstance(value, basestring):
value = value.replace('$$', '$')
except (InterpolationError, ValueError) as error: except (InterpolationError, ValueError) as error:
raise ExpConfigError(error.message, key) raise ExpConfigError(error.message, key)
section[key] = value section[key] = value
...@@ -454,6 +470,7 @@ class ExpConfig(ConfigObj): ...@@ -454,6 +470,7 @@ class ExpConfig(ConfigObj):
config_lines.seek(0) config_lines.seek(0)
ConfigObj.__init__(self, config_lines, interpolation=False) ConfigObj.__init__(self, config_lines, interpolation=False)
self.walk(uneval_key)
self.experiment_id = self[ExpConfig.id_name] self.experiment_id = self[ExpConfig.id_name]
self.experiment_kind = re.sub(r'-\w+$', '', experiment_type) self.experiment_kind = re.sub(r'-\w+$', '', experiment_type)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment