Gentoo Archives: gentoo-catalyst

From: Brian Dolbec <dolsen@g.o>
To: gentoo-catalyst@l.g.o
Subject: [gentoo-catalyst] [PATCH 5/6] Extend ParserBase to do variable substitution.
Date: Thu, 11 Sep 2014 04:01:24
Message-Id: 1410408068-3441-6-git-send-email-dolsen@gentoo.org
In Reply to: [gentoo-catalyst] [PATCH 0/6] Various changes towards 3.0 branch by Brian Dolbec
1 Also add embedded variable substitiution to default settings.
2 Why are we not using python's built-in ConfigParser?
3 We'll migrate it later.
4 ---
5 catalyst/config.py | 3 +++
6 catalyst/main.py | 6 +++++-
7 2 files changed, 8 insertions(+), 1 deletion(-)
8
9 diff --git a/catalyst/config.py b/catalyst/config.py
10 index 8b23342..bf3c7c6 100644
11 --- a/catalyst/config.py
12 +++ b/catalyst/config.py
13 @@ -66,6 +66,9 @@ class ParserBase:
14 # Start a new array using the first element of mobjs
15 cur_array = [mobjs[0]]
16 if mobjs[1]:
17 + # do any variable substitiution embeded in it with
18 + # the values already obtained
19 + mobjs[1] = mobjs[1] % values
20 if self.multiple_values:
21 # split on white space creating additional array elements
22 # subarray = white_space.split(mobjs[1])
23 diff --git a/catalyst/main.py b/catalyst/main.py
24 index 1446cf9..5fa3f1b 100644
25 --- a/catalyst/main.py
26 +++ b/catalyst/main.py
27 @@ -116,7 +116,6 @@ def parse_config(myconfig):
28 # add our python base directory to use for loading target arch's
29 conf_values["PythonDir"] = __selfpath__
30
31 -
32 # print out any options messages
33 for opt in conf_values['options']:
34 if opt in option_messages:
35 @@ -133,6 +132,11 @@ def parse_config(myconfig):
36 if "envscript" in myconf:
37 print "Envscript support enabled."
38
39 + # take care of any variable substitutions that may be left
40 + for x in list(conf_values):
41 + if isinstance(conf_values[x], str):
42 + conf_values[x] = conf_values[x] % conf_values
43 +
44
45 def import_module(target):
46 """
47 --
48 2.1.0