summaryrefslogtreecommitdiffstats
path: root/src/engine/SCons
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2002-03-14 02:57:20 (GMT)
committerSteven Knight <knight@baldmt.com>2002-03-14 02:57:20 (GMT)
commitd274d685b3fae62354a7c3deb0622e2edd81b0c7 (patch)
tree4dac018073b8fb70d35c03c4e4ad17e0b75e5142 /src/engine/SCons
parenta441c8d1cc8bf1ed0817b4b1deb9ff2e912bb9f0 (diff)
downloadSCons-d274d685b3fae62354a7c3deb0622e2edd81b0c7.zip
SCons-d274d685b3fae62354a7c3deb0622e2edd81b0c7.tar.gz
SCons-d274d685b3fae62354a7c3deb0622e2edd81b0c7.tar.bz2
Swap the global and local arguments in scons_subst*() to match the Python convention for exec().
Diffstat (limited to 'src/engine/SCons')
-rw-r--r--src/engine/SCons/Util.py10
-rw-r--r--src/engine/SCons/UtilTests.py11
2 files changed, 16 insertions, 5 deletions
diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py
index 6806c31..04e7e7d 100644
--- a/src/engine/SCons/Util.py
+++ b/src/engine/SCons/Util.py
@@ -170,7 +170,7 @@ class PathList(UserList.UserList):
_cv = re.compile(r'\$([_a-zA-Z]\w*|{[^}]*})')
_space_sep = re.compile(r'[\t ]+(?![^{]*})')
-def scons_subst_list(strSubst, locals, globals, remove=None):
+def scons_subst_list(strSubst, globals, locals, remove=None):
"""
This function is similar to scons_subst(), but with
one important difference. Instead of returning a single
@@ -189,12 +189,12 @@ def scons_subst_list(strSubst, locals, globals, remove=None):
This is the only way to know where the 'split' between arguments
is for executing a command line."""
- def repl(m, locals=locals, globals=globals):
+ def repl(m, globals=globals, locals=locals):
key = m.group(1)
if key[:1] == '{' and key[-1:] == '}':
key = key[1:-1]
try:
- e = eval(key, locals, globals)
+ e = eval(key, globals, locals)
if not e:
s = ''
elif is_List(e):
@@ -219,7 +219,7 @@ def scons_subst_list(strSubst, locals, globals, remove=None):
return map(lambda x: filter(lambda y: y, string.split(x, '\0')),
listLines)
-def scons_subst(strSubst, locals, globals, remove=None):
+def scons_subst(strSubst, globals, locals, remove=None):
"""Recursively interpolates dictionary variables into
the specified string, returning the expanded result.
Variables are specified by a $ prefix in the string and
@@ -229,7 +229,7 @@ def scons_subst(strSubst, locals, globals, remove=None):
surrounded by curly braces to separate the name from
trailing characters.
"""
- cmd_list = scons_subst_list(strSubst, locals, globals, remove)
+ cmd_list = scons_subst_list(strSubst, globals, locals, remove)
return string.join(map(string.join, cmd_list), '\n')
class VarInterpolator:
diff --git a/src/engine/SCons/UtilTests.py b/src/engine/SCons/UtilTests.py
index aa58c8e..f3569f0 100644
--- a/src/engine/SCons/UtilTests.py
+++ b/src/engine/SCons/UtilTests.py
@@ -155,6 +155,11 @@ class UtilTestCase(unittest.TestCase):
newcom = scons_subst("test aXbXcXd", loc, {}, re.compile('X'))
assert newcom == cvt("test abcd"), newcom
+ glob = { 'a' : 1, 'b' : 2 }
+ loc = {'a' : 3, 'c' : 4 }
+ newcom = scons_subst("test $a $b $c $d test", glob, loc)
+ assert newcom == "test 3 2 4 test", newcom
+
def test_subst_list(self):
"""Testing the scons_subst_list() method..."""
loc = {}
@@ -188,6 +193,12 @@ class UtilTestCase(unittest.TestCase):
assert cmd_list[1][0] == 'after', cmd_list[1][0]
assert cmd_list[0][2] == cvt('../foo/ack.cbefore'), cmd_list[0][2]
+ glob = { 'a' : 1, 'b' : 2 }
+ loc = {'a' : 3, 'c' : 4 }
+ cmd_list = scons_subst_list("test $a $b $c $d test", glob, loc)
+ assert len(cmd_list) == 1, cmd_list
+ assert cmd_list[0] == ['test', '3', '2', '4', 'test'], cmd_list
+
def test_autogenerate(dict):
"""Test autogenerating variables in a dictionary."""
dict = {'LIBS' : [ 'foo', 'bar', 'baz' ],