summaryrefslogtreecommitdiffstats
path: root/src/engine
diff options
context:
space:
mode:
authorWilliam Deegan <bill@baddogconsulting.com>2017-02-27 19:30:51 (GMT)
committerWilliam Deegan <bill@baddogconsulting.com>2017-02-27 19:30:51 (GMT)
commit4b917bc012fd755f4f72d67e2291bd06ef9ffa63 (patch)
tree8fcdb76361b510de5524bb63b057aff69f4942bb /src/engine
parent314e1ead8ce83fcdc187c551d2d49549c80eabf3 (diff)
downloadSCons-4b917bc012fd755f4f72d67e2291bd06ef9ffa63.zip
SCons-4b917bc012fd755f4f72d67e2291bd06ef9ffa63.tar.gz
SCons-4b917bc012fd755f4f72d67e2291bd06ef9ffa63.tar.bz2
change NodeList to work for both py2/py3. default __getitem__ didn't work with NodeList.method for slices under py3
Diffstat (limited to 'src/engine')
-rw-r--r--src/engine/SCons/Util.py32
1 files changed, 29 insertions, 3 deletions
diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py
index a98ce08..6d307cb 100644
--- a/src/engine/SCons/Util.py
+++ b/src/engine/SCons/Util.py
@@ -42,6 +42,8 @@ try:
except ImportError as e:
from collections import UserList
+from collections import Iterable
+
try:
from UserString import UserString
except ImportError as e:
@@ -131,6 +133,22 @@ class NodeList(UserList):
>>> someList.strip()
[ 'foo', 'bar' ]
"""
+
+# def __init__(self, initlist=None):
+# self.data = []
+# # print("TYPE:%s"%type(initlist))
+# if initlist is not None:
+# # XXX should this accept an arbitrary sequence?
+# if type(initlist) == type(self.data):
+# self.data[:] = initlist
+# elif isinstance(initlist, (UserList, NodeList)):
+# self.data[:] = initlist.data[:]
+# elif isinstance(initlist, Iterable):
+# self.data = list(initlist)
+# else:
+# self.data = [ initlist,]
+
+
def __nonzero__(self):
return len(self.data) != 0
@@ -158,9 +176,17 @@ class NodeList(UserList):
breaking slicing nodelist and refering to
properties and methods on contained object
"""
- return self.__class__(self.data[index])
-
-
+# return self.__class__(self.data[index])
+
+ if isinstance(index, slice):
+ # Expand the slice object using range()
+ # limited by number of items in self.data
+ indices = index.indices(len(self.data))
+ return self.__class__([self[x] for x in
+ range(*indices)])
+ else:
+ # Return one item of the tart
+ return self.data[index]
_get_env_var = re.compile(r'^\$([_a-zA-Z]\w*|{[_a-zA-Z]\w*})$')