summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2002-03-22 17:21:00 (GMT)
committerSteven Knight <knight@baldmt.com>2002-03-22 17:21:00 (GMT)
commit2b87cbae264462efe494aa7ee07841ffb7ebaa0d (patch)
tree012844c97585092e3af23aeac926ac2ba8c58712
parent8587b92b72c166857467b2f718560148a9549ad3 (diff)
downloadSCons-2b87cbae264462efe494aa7ee07841ffb7ebaa0d.zip
SCons-2b87cbae264462efe494aa7ee07841ffb7ebaa0d.tar.gz
SCons-2b87cbae264462efe494aa7ee07841ffb7ebaa0d.tar.bz2
Make env['FOO'] by shorthand for env.Dictionary()['FOO'] (Anthony Roach)
-rw-r--r--doc/man/scons.16
-rw-r--r--src/engine/SCons/Environment.py9
-rw-r--r--src/engine/SCons/EnvironmentTests.py6
3 files changed, 21 insertions, 0 deletions
diff --git a/doc/man/scons.1 b/doc/man/scons.1
index 5d8a0a5..16c5e6b 100644
--- a/doc/man/scons.1
+++ b/doc/man/scons.1
@@ -994,6 +994,12 @@ dict = env.Dictionary()
dict["CC"] = "cc"
.EE
+or using the [] operator:
+
+.ES
+env["CC"] = "cc"
+.EE
+
Construction variables can also be passed to the construction environment
constructor:
diff --git a/src/engine/SCons/Environment.py b/src/engine/SCons/Environment.py
index d997d6f..65af179 100644
--- a/src/engine/SCons/Environment.py
+++ b/src/engine/SCons/Environment.py
@@ -227,6 +227,15 @@ class Environment:
dlist = dlist[0]
return dlist
+ def __setitem__(self, key, value):
+ self._dict[key] = value
+
+ def __getitem__(self, key):
+ return self._dict[key]
+
+ def __delitem__(self, key):
+ del self._dict[key]
+
def Command(self, target, source, action):
"""Builds the supplied target files from the supplied
source files using the supplied action. Action may
diff --git a/src/engine/SCons/EnvironmentTests.py b/src/engine/SCons/EnvironmentTests.py
index 86f179a..654d432 100644
--- a/src/engine/SCons/EnvironmentTests.py
+++ b/src/engine/SCons/EnvironmentTests.py
@@ -195,6 +195,12 @@ class EnvironmentTestCase(unittest.TestCase):
assert env.Dictionary().has_key('CCFLAGS')
assert env.Dictionary().has_key('ENV')
+ assert env['XXX'] == 'x'
+ env['XXX'] = 'foo'
+ assert env.Dictionary('XXX') == 'foo'
+ del env['XXX']
+ assert not env.Dictionary().has_key('XXX')
+
def test_ENV(self):
"""Test setting the external ENV in Environments
"""