diff options
author | Steven Knight <knight@baldmt.com> | 2001-09-26 13:46:18 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2001-09-26 13:46:18 (GMT) |
commit | ad5b73702125ef8deadf2231bb804e54ac128399 (patch) | |
tree | dd54eb9e13de5d37da463c6540ee04f5491773b7 /src/engine | |
parent | 7318c163cf3f9e5a3c17404ef8bec15454b9766b (diff) | |
download | SCons-ad5b73702125ef8deadf2231bb804e54ac128399.zip SCons-ad5b73702125ef8deadf2231bb804e54ac128399.tar.gz SCons-ad5b73702125ef8deadf2231bb804e54ac128399.tar.bz2 |
Change the env.Dictionary to an access method for an env._dict attribute.
Diffstat (limited to 'src/engine')
-rw-r--r-- | src/engine/SCons/Environment.py | 18 | ||||
-rw-r--r-- | src/engine/SCons/EnvironmentTests.py | 18 |
2 files changed, 24 insertions, 12 deletions
diff --git a/src/engine/SCons/Environment.py b/src/engine/SCons/Environment.py index 5561cce..508392b 100644 --- a/src/engine/SCons/Environment.py +++ b/src/engine/SCons/Environment.py @@ -53,7 +53,7 @@ class Environment: """ def __init__(self, **kw): - self.Dictionary = {} + self._dict = {} if kw.has_key('BUILDERS'): builders = kw['BUILDERS'] if not type(builders) is types.ListType: @@ -61,7 +61,7 @@ class Environment: else: import SCons.Defaults kw['BUILDERS'] = SCons.Defaults.Builders[:] - self.Dictionary.update(copy.deepcopy(kw)) + self._dict.update(copy.deepcopy(kw)) class BuilderWrapper: """Wrapper class that allows an environment to @@ -83,7 +83,7 @@ class Environment: def __cmp__(self, other): - return cmp(self.Dictionary, other.Dictionary) + return cmp(self._dict, other._dict) def Builders(self): pass # XXX @@ -107,7 +107,7 @@ class Environment: """Update an existing construction Environment with new construction variables and/or values. """ - self.Dictionary.update(copy.deepcopy(kw)) + self._dict.update(copy.deepcopy(kw)) def Depends(self, target, dependency): """Explicity specify that 'target's depend on 'dependency'.""" @@ -120,6 +120,14 @@ class Environment: tlist = tlist[0] return tlist + def Dictionary(self, *args): + if not args: + return self._dict + dlist = map(lambda x, s=self: s._dict[x], args) + if len(dlist) == 1: + dlist = dlist[0] + return dlist + def subst(self, string): """Recursively interpolates construction variables from the Environment into the specified string, returning the expanded @@ -134,7 +142,7 @@ class Environment: key = m.group(1) if key[:1] == '{' and key[-1:] == '}': key = key[1:-1] - if _self.Dictionary.has_key(key): return _self.Dictionary[key] + if _self._dict.has_key(key): return _self._dict[key] else: return '' n = 1 while n != 0: diff --git a/src/engine/SCons/EnvironmentTests.py b/src/engine/SCons/EnvironmentTests.py index 149ba74..0488173 100644 --- a/src/engine/SCons/EnvironmentTests.py +++ b/src/engine/SCons/EnvironmentTests.py @@ -75,9 +75,9 @@ class EnvironmentTestCase(unittest.TestCase): assert env1 == env1copy env3 = env1.Copy(XXX = 'x3', ZZZ = 'z3') - assert env3.Dictionary['XXX'] == 'x3' - assert env3.Dictionary['YYY'] == 'y' - assert env3.Dictionary['ZZZ'] == 'z3' + assert env3.Dictionary('XXX') == 'x3' + assert env3.Dictionary('YYY') == 'y' + assert env3.Dictionary('ZZZ') == 'z3' assert env1 == env1copy def test_Dictionary(self): @@ -86,10 +86,14 @@ class EnvironmentTestCase(unittest.TestCase): Fetch them from the Dictionary and check for well-known defaults that get inserted. """ - env = Environment(XXX = 'x', YYY = 'y') - assert env.Dictionary['XXX'] == 'x' - assert env.Dictionary['YYY'] == 'y' - assert env.Dictionary.has_key('BUILDERS') + env = Environment(XXX = 'x', YYY = 'y', ZZZ = 'z') + assert env.Dictionary('XXX') == 'x' + assert env.Dictionary('YYY') == 'y' + assert env.Dictionary('XXX', 'ZZZ') == ['x', 'z'] + xxx, zzz = env.Dictionary('XXX', 'ZZZ') + assert xxx == 'x' + assert zzz == 'z' + assert env.Dictionary().has_key('BUILDERS') def test_Environment(self): """Test construction Environments creation |