simplify the loop in Node.listchain

This commit is contained in:
Ronny Pfannschmidt 2011-12-01 19:36:44 +01:00
parent d965101f6a
commit 0c8e71faa5
2 changed files with 8 additions and 7 deletions

View File

@ -29,6 +29,7 @@ Changes between 2.1.3 and 2.2.0
- fix issue83: link to generated funcarg list - fix issue83: link to generated funcarg list
- fix issue74: pyarg module names are now checked against imp.find_module false positives - fix issue74: pyarg module names are now checked against imp.find_module false positives
- fix compatibility with twisted/trial-11.1.0 use cases - fix compatibility with twisted/trial-11.1.0 use cases
- simplify Node.listchain
Changes between 2.1.2 and 2.1.3 Changes between 2.1.2 and 2.1.3
---------------------------------------- ----------------------------------------

View File

@ -229,13 +229,13 @@ class Node(object):
def listchain(self): def listchain(self):
""" return list of all parent collectors up to self, """ return list of all parent collectors up to self,
starting from root of collection tree. """ starting from root of collection tree. """
l = [self] chain = []
while 1: item = self
x = l[0] while item is not None:
if x.parent is not None: # and x.parent.parent is not None: chain.append(item)
l.insert(0, x.parent) item = item.parent
else: chain.reverse()
return l return chain
def listnames(self): def listnames(self):
return [x.name for x in self.listchain()] return [x.name for x in self.listchain()]