Add an internal Environment._update() method that updates the dictionary directly...
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Mon, 23 Feb 2004 08:09:40 +0000 (08:09 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Mon, 23 Feb 2004 08:09:40 +0000 (08:09 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@905 fdb21ef1-2011-0410-befe-b5e4ea1792b1

src/engine/SCons/BuilderTests.py
src/engine/SCons/Environment.py
src/engine/SCons/EnvironmentTests.py
src/engine/SCons/ExecutorTests.py
src/engine/SCons/Node/FSTests.py

index b03a99e960a532b76334d55d49cf817f22766489..bd41f099b8ceaa17845d83faa58d8bbbcffbf217 100644 (file)
@@ -113,6 +113,8 @@ class Environment:
         env = apply(Environment, (), self.d)
         env.d.update(overrides)
         return env
+    def _update(self, dict):
+        self.d.update(dict)
     def items(self):
         return self.d.items()
     def sig_dict(self):
index 5f8575eb96e193175cd7406473dbf0578a6c5419..a6262046014c5be07b77ea1f510ce310364ac05e 100644 (file)
@@ -392,6 +392,12 @@ class Base:
         the documentation for that function."""
         return SCons.Util.scons_subst_list(string, self, raw, target, source, dict)
 
+    def _update(self, dict):
+        """Update an environment's values directly, bypassing the normal
+        checks that occur when users try to set items.
+        """
+        self._dict.update(dict)
+
     def use_build_signature(self):
         try:
             return self._build_signature
index 3a0e79ea4a06ba877dbe76d42f216f06d7cccda7..330bb7c2cbdbeb8f888a850cdeee95923267fc16 100644 (file)
@@ -798,6 +798,26 @@ class EnvironmentTestCase(unittest.TestCase):
         x = s("${_concat(PRE, LIST, SUF, __env__)}")
         assert x == 'preasuf prebsuf', x
 
+    def test__update(self):
+        """Test the _update() method"""
+        env = Environment(X = 'x', Y = 'y', Z = 'z')
+        assert env['X'] == 'x', env['X']
+        assert env['Y'] == 'y', env['Y']
+        assert env['Z'] == 'z', env['Z']
+        env._update({'X'       : 'xxx',
+                     'TARGET'  : 't',
+                     'TARGETS' : 'ttt',
+                     'SOURCE'  : 's',
+                     'SOURCES' : 'sss',
+                     'Z'       : 'zzz'})
+        assert env['X'] == 'xxx', env['X']
+        assert env['Y'] == 'y', env['Y']
+        assert env['Z'] == 'zzz', env['Z']
+        assert env['TARGET'] == 't', env['TARGET']
+        assert env['TARGETS'] == 'ttt', env['TARGETS']
+        assert env['SOURCE'] == 's', env['SOURCE']
+        assert env['SOURCES'] == 'sss', env['SOURCES']
+
 
 
     def test_Append(self):
index 2cdc0e2321993d412c59411fa11e94524ebb5275..d43f7e20f9355c451738447110e838de5a0019b3 100644 (file)
@@ -38,6 +38,8 @@ class MyEnvironment:
         d = self._dict.copy()
         d.update(overrides)
         return d
+    def _update(self, dict):
+        self._dict.update(dict)
 
 class MyAction:
     actions = ['action1', 'action2']
index 35ccead55f42aaddc802ec2ce897e54445e778b0..85ae4d9fe58fea72646d0179a24225eb65ed406c 100644 (file)
@@ -72,6 +72,8 @@ class Environment:
         return self.scanner
     def Override(self, overrides):
         return self
+    def _update(self, dict):
+        pass
 
 class Action:
     def __call__(self, targets, sources, env):