def __iter__(self):
stack = [ (self.__graphRoot, chain(self.__pkgRoot.getDirectDepSteps(),
self.__pkgRoot.getIndirectDepSteps())) ]
yield (self.__graphRoot, self.__pkgRoot)
done = set([self.__graphRoot.key()])
while stack:
try:
childPkg = next(stack[-1][1]).getPackage()
childNode = stack[-1][0][childPkg.getName()].node
if childNode.key() not in done:
done.add(childNode.key())
yield (childNode, childPkg)
stack.append( (childNode, chain(childPkg.getDirectDepSteps(),
childPkg.getIndirectDepSteps())) )
except StopIteration:
stack.pop()
评论列表
文章目录