From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 272AC1387FD for ; Thu, 11 Sep 2014 04:01:24 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 69395E0A6B; Thu, 11 Sep 2014 04:01:18 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id C6E12E0A63 for ; Thu, 11 Sep 2014 04:01:17 +0000 (UTC) Received: from big_daddy.dol-sen.ca (S010600222de111ff.vc.shawcable.net [96.49.5.156]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: dolsen) by smtp.gentoo.org (Postfix) with ESMTPSA id DF8153401FE for ; Thu, 11 Sep 2014 04:01:16 +0000 (UTC) From: Brian Dolbec 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 Message-Id: <1410408068-3441-6-git-send-email-dolsen@gentoo.org> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1410408068-3441-1-git-send-email-dolsen@gentoo.org> References: <1410408068-3441-1-git-send-email-dolsen@gentoo.org> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-catalyst@lists.gentoo.org Reply-to: gentoo-catalyst@lists.gentoo.org X-Archives-Salt: 439cc469-2bb7-4365-8759-f228a30b6923 X-Archives-Hash: db885a118375cb8b3a66534dee732205 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