diff options
author | Steven Knight <knight@baldmt.com> | 2004-02-23 08:09:40 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2004-02-23 08:09:40 (GMT) |
commit | 027b93825c3b594b46e5edb9bf33af8089cbf7a4 (patch) | |
tree | 54b9d3e851b50f299e7f6857ac9ce048b3b197f8 | |
parent | 50c144a3e0ea77718bba6762684c07398f8a05af (diff) | |
download | SCons-027b93825c3b594b46e5edb9bf33af8089cbf7a4.zip SCons-027b93825c3b594b46e5edb9bf33af8089cbf7a4.tar.gz SCons-027b93825c3b594b46e5edb9bf33af8089cbf7a4.tar.bz2 |
Add an internal Environment._update() method that updates the dictionary directly without running through user protections.
-rw-r--r-- | src/engine/SCons/BuilderTests.py | 2 | ||||
-rw-r--r-- | src/engine/SCons/Environment.py | 6 | ||||
-rw-r--r-- | src/engine/SCons/EnvironmentTests.py | 20 | ||||
-rw-r--r-- | src/engine/SCons/ExecutorTests.py | 2 | ||||
-rw-r--r-- | src/engine/SCons/Node/FSTests.py | 2 |
5 files changed, 32 insertions, 0 deletions
diff --git a/src/engine/SCons/BuilderTests.py b/src/engine/SCons/BuilderTests.py index b03a99e..bd41f09 100644 --- a/src/engine/SCons/BuilderTests.py +++ b/src/engine/SCons/BuilderTests.py @@ -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): diff --git a/src/engine/SCons/Environment.py b/src/engine/SCons/Environment.py index 5f8575e..a626204 100644 --- a/src/engine/SCons/Environment.py +++ b/src/engine/SCons/Environment.py @@ -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 diff --git a/src/engine/SCons/EnvironmentTests.py b/src/engine/SCons/EnvironmentTests.py index 3a0e79e..330bb7c 100644 --- a/src/engine/SCons/EnvironmentTests.py +++ b/src/engine/SCons/EnvironmentTests.py @@ -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): diff --git a/src/engine/SCons/ExecutorTests.py b/src/engine/SCons/ExecutorTests.py index 2cdc0e2..d43f7e2 100644 --- a/src/engine/SCons/ExecutorTests.py +++ b/src/engine/SCons/ExecutorTests.py @@ -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'] diff --git a/src/engine/SCons/Node/FSTests.py b/src/engine/SCons/Node/FSTests.py index 35ccead..85ae4d9 100644 --- a/src/engine/SCons/Node/FSTests.py +++ b/src/engine/SCons/Node/FSTests.py @@ -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): |