diff options
| author | Steven Knight <knight@baldmt.com> | 2004-02-16 06:09:44 (GMT) |
|---|---|---|
| committer | Steven Knight <knight@baldmt.com> | 2004-02-16 06:09:44 (GMT) |
| commit | caeea730e14a9f9f7f532d168aac351f3726ecfc (patch) | |
| tree | 1d6abfe0ea36e04fab967178a0ecdb553ff63480 /src/engine/SCons/Environment.py | |
| parent | 9c118de758d6b40a085446ef19299faa196c85e2 (diff) | |
| download | SCons-caeea730e14a9f9f7f532d168aac351f3726ecfc.zip SCons-caeea730e14a9f9f7f532d168aac351f3726ecfc.tar.gz SCons-caeea730e14a9f9f7f532d168aac351f3726ecfc.tar.bz2 | |
Add AppendUnique() and PrependUnique() Environment methods. Fix using the qt Tool from a copied construction environment.
Diffstat (limited to 'src/engine/SCons/Environment.py')
| -rw-r--r-- | src/engine/SCons/Environment.py | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/engine/SCons/Environment.py b/src/engine/SCons/Environment.py index 46897ef..900b1e1 100644 --- a/src/engine/SCons/Environment.py +++ b/src/engine/SCons/Environment.py @@ -454,6 +454,31 @@ class Base: self._dict[envname][name] = nv + def AppendUnique(self, **kw): + """Append values to existing construction variables + in an Environment, if they're not already there. + """ + kw = our_deepcopy(kw) + for key, val in kw.items(): + if not self._dict.has_key(key): + self._dict[key] = val + elif SCons.Util.is_Dict(self._dict[key]) and \ + SCons.Util.is_Dict(val): + self._dict[key].update(val) + elif SCons.Util.is_List(val): + dk = self._dict[key] + if not SCons.Util.is_List(dk): + dk = [dk] + val = filter(lambda x, dk=dk: x not in dk, val) + self._dict[key] = dk + val + else: + dk = self._dict[key] + if SCons.Util.is_List(dk): + if not val in dk: + self._dict[key] = dk + val + else: + self._dict[key] = self._dict[key] + val + def Copy(self, tools=None, toolpath=[], **kw): """Return a copy of a construction Environment. The copy is like a Python "deep copy"--that is, independent @@ -623,6 +648,31 @@ class Base: self._dict[envname][name] = nv + def PrependUnique(self, **kw): + """Append values to existing construction variables + in an Environment, if they're not already there. + """ + kw = our_deepcopy(kw) + for key, val in kw.items(): + if not self._dict.has_key(key): + self._dict[key] = val + elif SCons.Util.is_Dict(self._dict[key]) and \ + SCons.Util.is_Dict(val): + self._dict[key].update(val) + elif SCons.Util.is_List(val): + dk = self._dict[key] + if not SCons.Util.is_List(dk): + dk = [dk] + val = filter(lambda x, dk=dk: x not in dk, val) + self._dict[key] = val + dk + else: + dk = self._dict[key] + if SCons.Util.is_List(dk): + if not val in dk: + self._dict[key] = val + dk + else: + self._dict[key] = val + dk + def Replace(self, **kw): """Replace existing construction variables in an Environment with new construction variables and/or values. |
