def walkTroveSet(self, topTrove, ignoreMissing = True,
                     withFiles=True, asTuple=True):
        """
        Generator returns all of the troves included by topTrove, including
        topTrove itself. It is a depth first search of strong refs. Punchouts
        are taken into account.

        @param asTuple: If True, (name, version, flavor) tuples are returned
        instead of Trove objects. This can be much faster.
        """
        def _collect(l, tup):
            if tup[1] is None:
                if trove.troveIsComponent(tup[0][0]):
                    # don't bother looking for children of components
                    tup[1] = []
                else:
                    l.append(tup)
            else:
                for t in tup[1]:
                    _collect(l, t)

        if asTuple and hasattr(self, 'getTroveTroves'):
            assert(not withFiles)
            seen = set()
            all = [ topTrove.getNameVersionFlavor(), None ]
            seen.add(topTrove.getNameVersionFlavor())
            while True:
                getList = []
                _collect(getList, all)
                if not getList:
                    break

                refs = self.getTroveTroves([ x[0] for x in getList],
                                               justPresent = True)

                for item, refList in itertools.izip(getList, refs):
                    item[1] = []
                    for x in refList:
                        if x not in seen:
                            seen.add(x)
                            item[1].append([x, None])

            stack = [ all ]
            while stack:
                next = stack.pop()
                yield next[0]
                stack += next[1]

            return

        def _format(trv):
            if asTuple:
                return trv.getNameVersionFlavor()
            else:
                return trv
        yield _format(topTrove)
        seen = { topTrove.getName() : [ (topTrove.getVersion(),
                                         topTrove.getFlavor()) ] }

        troveList = [x for x in sorted(topTrove.iterTroveList(strongRefs=True))]

        while troveList:
            (name, version, flavor) = troveList[0]
            del troveList[0]

            if seen.has_key(name):
                match = False
                for (ver, fla) in seen[name]:
                    if version == ver and fla == flavor:
                        match = True
                        break
                if match: continue

                seen[name].append((version, flavor))
            else:
                seen[name] = [ (version, flavor) ]

            try:
                trv = self.getTrove(name, version, flavor, withFiles=withFiles)

                yield _format(trv)

                troveList = ([ x for x in
                                sorted(trv.iterTroveList(strongRefs=True)) ]
                              + troveList)
            except errors.TroveMissing:
                if not ignoreMissing:
                    raise
            except __HOLE__:
                if not ignoreMissing:
                    raise
dataset/ETHPy150Open sassoftware/conary/conary/repository/trovesource.py/AbstractTroveSource.walkTroveSet