1 |
commit: fa577bb409c36c3b38a90f65cb7a665c5474d2c9 |
2 |
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org> |
3 |
AuthorDate: Fri Jan 25 04:00:24 2013 +0000 |
4 |
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu Jan 1 05:58:06 2015 +0000 |
6 |
URL: http://sources.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=fa577bb4 |
7 |
|
8 |
Extend ParserBase to do variable substitution. |
9 |
|
10 |
Also add embedded variable substitiution to default settings. |
11 |
Why are we not using python's built-in ConfigParser? |
12 |
We'll migrate it later. |
13 |
|
14 |
--- |
15 |
catalyst/config.py | 3 +++ |
16 |
catalyst/main.py | 6 +++++- |
17 |
2 files changed, 8 insertions(+), 1 deletion(-) |
18 |
|
19 |
diff --git a/catalyst/config.py b/catalyst/config.py |
20 |
index 8b23342..bf3c7c6 100644 |
21 |
--- a/catalyst/config.py |
22 |
+++ b/catalyst/config.py |
23 |
@@ -66,6 +66,9 @@ class ParserBase: |
24 |
# Start a new array using the first element of mobjs |
25 |
cur_array = [mobjs[0]] |
26 |
if mobjs[1]: |
27 |
+ # do any variable substitiution embeded in it with |
28 |
+ # the values already obtained |
29 |
+ mobjs[1] = mobjs[1] % values |
30 |
if self.multiple_values: |
31 |
# split on white space creating additional array elements |
32 |
# subarray = white_space.split(mobjs[1]) |
33 |
|
34 |
diff --git a/catalyst/main.py b/catalyst/main.py |
35 |
index 1446cf9..5fa3f1b 100644 |
36 |
--- a/catalyst/main.py |
37 |
+++ b/catalyst/main.py |
38 |
@@ -116,7 +116,6 @@ def parse_config(myconfig): |
39 |
# add our python base directory to use for loading target arch's |
40 |
conf_values["PythonDir"] = __selfpath__ |
41 |
|
42 |
- |
43 |
# print out any options messages |
44 |
for opt in conf_values['options']: |
45 |
if opt in option_messages: |
46 |
@@ -133,6 +132,11 @@ def parse_config(myconfig): |
47 |
if "envscript" in myconf: |
48 |
print "Envscript support enabled." |
49 |
|
50 |
+ # take care of any variable substitutions that may be left |
51 |
+ for x in list(conf_values): |
52 |
+ if isinstance(conf_values[x], str): |
53 |
+ conf_values[x] = conf_values[x] % conf_values |
54 |
+ |
55 |
|
56 |
def import_module(target): |
57 |
""" |