From: Brian Dolbec <dolsen@gentoo.org>
To: gentoo-catalyst@lists.gentoo.org
Subject: [gentoo-catalyst] [PATCH 5/6] Extend ParserBase to do variable substitution.
Date: Wed, 10 Sep 2014 21:01:07 -0700 [thread overview]
Message-ID: <1410408068-3441-6-git-send-email-dolsen@gentoo.org> (raw)
In-Reply-To: <1410408068-3441-1-git-send-email-dolsen@gentoo.org>
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 | 3 +++
catalyst/main.py | 6 +++++-
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/catalyst/config.py b/catalyst/config.py
index 8b23342..bf3c7c6 100644
--- a/catalyst/config.py
+++ b/catalyst/config.py
@@ -66,6 +66,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 1446cf9..5fa3f1b 100644
--- a/catalyst/main.py
+++ b/catalyst/main.py
@@ -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):
"""
--
2.1.0
next prev parent reply other threads:[~2014-09-11 4:01 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-11 4:01 [gentoo-catalyst] [PATCH 0/6] Various changes towards 3.0 branch Brian Dolbec
2014-09-11 4:01 ` [gentoo-catalyst] [PATCH 1/6] FIXME! Comment out a small code block causing TypeError Brian Dolbec
2014-09-11 4:01 ` [gentoo-catalyst] [PATCH 2/6] Break out more repeated (path1 + path2)'s Brian Dolbec
2014-09-11 4:01 ` [gentoo-catalyst] [PATCH 3/6] Rename a make.conf key to make_conf due to bash variable name restrictions Brian Dolbec
2014-09-11 4:01 ` [gentoo-catalyst] [PATCH 4/6] reduce 2 operations into one simpler one Brian Dolbec
2014-09-11 4:01 ` Brian Dolbec [this message]
2014-09-11 4:01 ` [gentoo-catalyst] [PATCH 6/6] Make shdir a complete path to ease it's use Brian Dolbec
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1410408068-3441-6-git-send-email-dolsen@gentoo.org \
--to=dolsen@gentoo.org \
--cc=gentoo-catalyst@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox