simplify the loop in Node.listchain
This commit is contained in:
		
							parent
							
								
									d965101f6a
								
							
						
					
					
						commit
						0c8e71faa5
					
				|  | @ -29,6 +29,7 @@ Changes between 2.1.3 and 2.2.0 | |||
| - fix issue83: link to generated funcarg list | ||||
| - fix issue74: pyarg module names are now checked against imp.find_module false positives | ||||
| - fix compatibility with twisted/trial-11.1.0 use cases | ||||
| - simplify Node.listchain | ||||
| 
 | ||||
| Changes between 2.1.2 and 2.1.3 | ||||
| ---------------------------------------- | ||||
|  |  | |||
|  | @ -229,13 +229,13 @@ class Node(object): | |||
|     def listchain(self): | ||||
|         """ return list of all parent collectors up to self, | ||||
|             starting from root of collection tree. """ | ||||
|         l = [self] | ||||
|         while 1: | ||||
|             x = l[0] | ||||
|             if x.parent is not None: # and x.parent.parent is not None: | ||||
|                 l.insert(0, x.parent) | ||||
|             else: | ||||
|                 return l | ||||
|         chain = [] | ||||
|         item = self | ||||
|         while item is not None: | ||||
|             chain.append(item) | ||||
|             item = item.parent | ||||
|         chain.reverse() | ||||
|         return chain | ||||
| 
 | ||||
|     def listnames(self): | ||||
|         return [x.name for x in self.listchain()] | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue