diff options
Diffstat (limited to 'src/engine/SCons/Variables/ListVariable.py')
-rw-r--r-- | src/engine/SCons/Variables/ListVariable.py | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/src/engine/SCons/Variables/ListVariable.py b/src/engine/SCons/Variables/ListVariable.py index 521fa4f..36b530a 100644 --- a/src/engine/SCons/Variables/ListVariable.py +++ b/src/engine/SCons/Variables/ListVariable.py @@ -46,6 +46,7 @@ Usage example: # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +from __future__ import generators ### KEEP FOR COMPATIBILITY FIXERS __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -54,7 +55,6 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" __all__ = ['ListVariable',] -import string import UserList import SCons.Util @@ -62,7 +62,7 @@ import SCons.Util class _ListVariable(UserList.UserList): def __init__(self, initlist=[], allowedElems=[]): - UserList.UserList.__init__(self, filter(None, initlist)) + UserList.UserList.__init__(self, [_f for _f in initlist if _f]) self.allowedElems = allowedElems[:] self.allowedElems.sort() @@ -85,7 +85,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 +97,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 +122,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 |