diff options
author | Luca Falavigna <dktrkranz@debian.org> | 2010-06-15 14:28:28 +0000 |
---|---|---|
committer | Luca Falavigna <dktrkranz@debian.org> | 2010-06-15 14:28:28 +0000 |
commit | 0ed55e71a9f4b9cda836c6a4a5408cece60db0c6 (patch) | |
tree | b1e82f6e428ac15ed9b4de93e48d8079420d537d /src/engine/SCons/Variables/ListVariable.py | |
parent | fe00e4f75ba00298c30d6854b245c2a42c6542b8 (diff) | |
parent | 738149c9bfb9965d013d01ef99f9bb1c2819e7e8 (diff) |
Merge commit 'upstream/2.0.0'
Diffstat (limited to 'src/engine/SCons/Variables/ListVariable.py')
-rw-r--r-- | src/engine/SCons/Variables/ListVariable.py | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/src/engine/SCons/Variables/ListVariable.py b/src/engine/SCons/Variables/ListVariable.py index 3ed755f..dbd5f4b 100644 --- a/src/engine/SCons/Variables/ListVariable.py +++ b/src/engine/SCons/Variables/ListVariable.py @@ -45,26 +45,23 @@ Usage example: # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# -__revision__ = "src/engine/SCons/Variables/ListVariable.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Variables/ListVariable.py 5023 2010/06/14 22:05:46 scons" # Know Bug: This should behave like a Set-Type, but does not really, # since elements can occur twice. __all__ = ['ListVariable',] -import string -import UserList +import collections import SCons.Util -class _ListVariable(UserList.UserList): +class _ListVariable(collections.UserList): def __init__(self, initlist=[], allowedElems=[]): - UserList.UserList.__init__(self, filter(None, initlist)) - self.allowedElems = allowedElems[:] - self.allowedElems.sort() + collections.UserList.__init__(self, [_f for _f in initlist if _f]) + self.allowedElems = sorted(allowedElems) def __cmp__(self, other): raise NotImplementedError @@ -85,7 +82,7 @@ class _ListVariable(UserList.UserList): if self.data == self.allowedElems: return 'all' else: - return string.join(self, ',') + return ','.join(self) def prepare_to_store(self): return self.__str__() @@ -97,12 +94,12 @@ def _converter(val, allowedElems, mapdict): elif val == 'all': val = allowedElems else: - val = filter(None, string.split(val, ',')) - val = map(lambda v, m=mapdict: m.get(v, v), val) - notAllowed = filter(lambda v, aE=allowedElems: not v in aE, val) + val = [_f for _f in val.split(',') if _f] + val = [mapdict.get(v, v) for v in val] + notAllowed = [v for v in val if not v in allowedElems] if notAllowed: raise ValueError("Invalid value(s) for option: %s" % - string.join(notAllowed, ',')) + ','.join(notAllowed)) return _ListVariable(val, allowedElems) @@ -122,15 +119,14 @@ def ListVariable(key, help, default, names, map={}): A 'package list' option may either be 'all', 'none' or a list of package names (separated by space). """ - names_str = 'allowed names: %s' % string.join(names, ' ') + names_str = 'allowed names: %s' % ' '.join(names) if SCons.Util.is_List(default): - default = string.join(default, ',') - help = string.join( - (help, '(all|none|comma-separated list of names)', names_str), - '\n ') + default = ','.join(default) + help = '\n '.join( + (help, '(all|none|comma-separated list of names)', names_str)) return (key, help, default, None, #_validator, - lambda val, elems=names, m=map: _converter(val, elems, m)) + lambda val: _converter(val, names, map)) # Local Variables: # tab-width:4 |