def _scanFilesystem(self, fullTroveList, dirType = NEW_FILES_OWNED_DIR):
        dirs = list(self.db.db.getTroveFiles(fullTroveList,
                                             onlyDirectories = True))
        skipDirs = dirset.DirectorySet(self.cfg.verifyDirsNoNewFiles)
        dirOwners = dirset.DirectoryDict()
        for trvInfo, dirName, stream in dirs:
            dirOwners[dirName] = trvInfo

        newFiles = []

        if dirType == NEW_FILES_ANY_DIR and '/' not in dirOwners:
            dirsToWalk = [ '/' ]
        else:
            dirsToWalk = sorted(dirOwners.itertops())

        dbPaths = self.db.db.getTroveFiles(fullTroveList)
        fsPaths = util.walkiter(dirsToWalk, skipPathSet = skipDirs,
                                root = self.cfg.root)
        lastDbPath = None
        lastFsPath = None

        try:
            for i in itertools.count(0):
                if lastDbPath is None:
                    trvInfo, lastDbPath, lastDbStream = dbPaths.next()
                if lastFsPath is None:
                    lastFsPath, lastFsStat = fsPaths.next()

                if lastDbPath < lastFsPath:
                    # in the database, but not the filesystem. that means
                    # it's gone missing, and we don't care much
                    lastDbPath = None
                elif lastDbPath > lastFsPath:
                    # it's in the filesystem, but not the database
                    if not stat.S_ISDIR(lastFsStat.st_mode):
                        newFiles.append(lastFsPath)
                    lastFsPath = None
                else:
                    # it's in both places
                    absPath = os.path.normpath(self.cfg.root + lastFsPath)
                    self.statCache[absPath] = lastFsStat
                    lastFsPath = None
                    lastDbPath = None
        except __HOLE__:
            pass

        # we don't need this, but drain the iterator
        [ x for x in dbPaths ]

        if lastFsPath and not stat.S_ISDIR(lastFsStat.st_mode):
            newFiles.append(lastFsPath)

        for lastFsPath, lastFsStat in fsPaths:
            if not stat.S_ISDIR(lastFsStat.st_mode):
                newFiles.append(lastFsPath)

        # newFiles is a list of files which have been locally added.
        # filter out ones which are owned by other troves. a bit silly
        # to do this if --all is used.
        areOwned = self.db.db.pathsOwned(newFiles)
        newFiles = [ path for path, isOwned in
                        itertools.izip(newFiles, areOwned)
                        if not isOwned ]

        # now turn newFiles into a dict which maps troves being verified to the
        # new files for that trove. byTrove[None] lists new files which no
        # trove claims ownership of
        byTrove = {}
        for path in newFiles:
            trvInfo = dirOwners.get(path, None)
            l = byTrove.setdefault(trvInfo, [])
            l.append(path)

        return byTrove
dataset/ETHPy150Open sassoftware/conary/conary/cmds/verify.py/_FindLocalChanges._scanFilesystem