Extend ParserBase to do variable substitution.
authorBrian Dolbec <dolsen@gentoo.org>
Fri, 25 Jan 2013 04:00:24 +0000 (20:00 -0800)
committerW. Trevor King <wking@tremily.us>
Sun, 15 Dec 2013 04:25:06 +0000 (20:25 -0800)
Also add embedded variable substitiution to default settings.
Why are we not using python's built-in ConfigParser?
We'll migrate it later.

catalyst/config.py
catalyst/main.py

index 0da1eb8e2191fa2951de127739c16612f931272c..c952648c234db66cefa76ee8fce1c06a9dcf9d8b 100644 (file)
@@ -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])
index db1818214457f538079e754dfeb9e645b6948747..043681e56a71315489e87041a76d2ab8caa58147 100755 (executable)
@@ -116,7 +116,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:
@@ -133,6 +132,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):
        """