diff options
author | Brian Dolbec <dolsen@gentoo.org> | 2013-01-24 20:00:24 -0800 |
---|---|---|
committer | Brian Dolbec <dolsen@gentoo.org> | 2013-11-21 21:44:39 -0800 |
commit | 3d19e92c00eda5a4afcce0cb2e355e63b6427fa3 (patch) | |
tree | 06b7fb480560193c9c764bb27ea567e9c3d41fb0 | |
parent | reduce 2 operations into one simpler one (diff) | |
download | catalyst-3d19e92c00eda5a4afcce0cb2e355e63b6427fa3.tar.gz catalyst-3d19e92c00eda5a4afcce0cb2e355e63b6427fa3.tar.bz2 catalyst-3d19e92c00eda5a4afcce0cb2e355e63b6427fa3.zip |
Extend ParserBase to do variable substitution.
Also add embedded variable substitiution to default settings.
Why are we not using python's built-in ConfigParser?
We'll migrate it later.
-rw-r--r-- | catalyst/config.py | 3 | ||||
-rw-r--r-- | catalyst/main.py | 6 |
2 files changed, 8 insertions, 1 deletions
diff --git a/catalyst/config.py b/catalyst/config.py index 0da1eb8e..c952648c 100644 --- a/catalyst/config.py +++ b/catalyst/config.py @@ -67,6 +67,9 @@ class ParserBase: # Start a new array using the first element of mobjs cur_array = [mobjs[0]] if mobjs[1]: + # do any variable substitiution embeded in it with + # the values already obtained + mobjs[1] = mobjs[1] % values if self.multiple_values: # split on white space creating additional array elements # subarray = white_space.split(mobjs[1]) diff --git a/catalyst/main.py b/catalyst/main.py index 2661cc7b..c9a2f0b4 100644 --- a/catalyst/main.py +++ b/catalyst/main.py @@ -118,7 +118,6 @@ def parse_config(myconfig): # add our python base directory to use for loading target arch's conf_values["PythonDir"] = __selfpath__ - # print out any options messages for opt in conf_values['options']: if opt in option_messages: @@ -135,6 +134,11 @@ def parse_config(myconfig): if "envscript" in myconf: print "Envscript support enabled." + # take care of any variable substitutions that may be left + for x in list(conf_values): + if isinstance(conf_values[x], str): + conf_values[x] = conf_values[x] % conf_values + def import_module(target): """ |