Пример #1
0
    def scan( self, rootpath=None ) :
        """Scan the rootpath and build the tree."""
        if rootpath :
            self._rootpath = rootpath
            self._root = None
        pathinfos = {}

        sizeColorProvider.reinitFileTree()
        for infopath in os.walk(self._rootpath,False) :
            #print "[%s]" % (pathinfos,)
            (path,subpaths,files) = infopath

            if path == self._rootpath :
                name = path
            else :
                name = os.path.split(path)[1]

            dirInfo = DirInfo( name=name, statInfo=os.lstat(path), tree=self )

            pathinfos[path] = dirInfo

            for file in files :
                completepath = os.path.join(path,file)
                try :
                    fileInfo = FileInfo( name=file, statInfo=os.lstat(completepath), tree=self, parent=dirInfo )
                    dirInfo.insertChild(fileInfo)
                except :
                    pass

            for subpath in subpaths :
                completepath = os.path.join(path,subpath)
                if completepath in pathinfos :
                    # print "[%s] : %d v (%s)" % (subpath,pathinfos[completepath].totalArea(),completepath)
                    dirInfo.insertChild(pathinfos[completepath])
                    # print "[%s] : %d ^ (%s)" % (subpath,pathinfos[completepath].totalArea(),completepath)
                    del pathinfos[completepath]

            dirInfo.finalizeLocal()

            if path == self._rootpath :
                self._root = dirInfo
        # print "[%s]" % (pathinfos,)
        return self._root
Пример #2
0
    def scan( self, rootpath=None ) :
        """Scan the rootpath and build the tree."""
        if rootpath :
            self._rootpath = rootpath
            self._root = None
        pathinfos = {}

        sizeColorProvider.reinitFileTree()

        exclude_list_re = []

        for exclude_item in self._exclude_list :
            exclude_list_re.append(re.compile('^'+str(exclude_item).replace('\\','\\\\').replace('.','\\.').replace('[','\\[').replace(']','\\]').replace('(','\\(').replace(')','\\)').replace('+','\\+').replace('*','.*').replace('?','.')+'$'))

        for exclude_item_re in self._exclude_list_re :
            exclude_list_re.append(re.compile(exclude_item_re))

        for infopath in self.file_provider().walk() :
            #print "[%s]" % (pathinfos,)
            (path,subpaths,files) = infopath

            if path == self._rootpath :
                name = path
            else :
                name = self.file_provider().split(path)[1]

            dirInfo = DirInfo( name=self.file_provider().get_clean_name(name), statInfo=self.file_provider().stat(path), tree=self )

            pathinfos[path] = dirInfo

            for file in files :
                exclude = False
                for exclude_item_re in exclude_list_re :
                    if exclude_item_re.match(file) :
                        exclude = True
                if not(exclude) :
                    completepath = self.file_provider().join(path,file)
                    try :
                        fileInfo = FileInfo( name=self.file_provider().get_clean_name(file), statInfo=self.file_provider().stat(completepath), tree=self, parent=dirInfo )
                        dirInfo.insertChild(fileInfo)
                    except :
                        pass

            for subpath in subpaths :
                exclude = False
                for exclude_item_re in exclude_list_re :
                    if exclude_item_re.match(subpath) :
                        exclude = True
                if not(exclude) :
                    completepath = self.file_provider().join(path,subpath)
                    if completepath in pathinfos :
                        # print "[%s] : %d v (%s)" % (subpath,pathinfos[completepath].totalArea(),completepath)
                        dirInfo.insertChild(pathinfos[completepath])
                        # print "[%s] : %d ^ (%s)" % (subpath,pathinfos[completepath].totalArea(),completepath)
                        del pathinfos[completepath]

            dirInfo.finalizeLocal()

            if path == self._rootpath :
                self._root = dirInfo
        # print "[%s]" % (pathinfos,)
        return self._root
Пример #3
0
    def scan(self, rootpath=None):
        """Scan the rootpath and build the tree."""
        if rootpath:
            self._rootpath = rootpath
            self._root = None
        pathinfos = {}

        sizeColorProvider.reinitFileTree()

        exclude_list_re = []

        for exclude_item in self._exclude_list:
            exclude_list_re.append(
                re.compile(
                    '^' + str(exclude_item).replace('\\', '\\\\').replace(
                        '.', '\\.').replace('[', '\\[').replace(']', '\\]').
                    replace('(', '\\(').replace(')', '\\)').replace(
                        '+', '\\+').replace('*', '.*').replace('?', '.') +
                    '$'))

        for exclude_item_re in self._exclude_list_re:
            exclude_list_re.append(re.compile(exclude_item_re))

        for infopath in self.file_provider().walk():
            #print "[%s]" % (pathinfos,)
            (path, subpaths, files) = infopath

            if path == self._rootpath:
                name = path
            else:
                name = self.file_provider().split(path)[1]

            dirInfo = DirInfo(name=self.file_provider().get_clean_name(name),
                              statInfo=self.file_provider().stat(path),
                              tree=self)

            pathinfos[path] = dirInfo

            for file in files:
                exclude = False
                for exclude_item_re in exclude_list_re:
                    if exclude_item_re.match(file):
                        exclude = True
                if not (exclude):
                    completepath = self.file_provider().join(path, file)
                    try:
                        fileInfo = FileInfo(
                            name=self.file_provider().get_clean_name(file),
                            statInfo=self.file_provider().stat(completepath),
                            tree=self,
                            parent=dirInfo)
                        dirInfo.insertChild(fileInfo)
                    except:
                        pass

            for subpath in subpaths:
                exclude = False
                for exclude_item_re in exclude_list_re:
                    if exclude_item_re.match(subpath):
                        exclude = True
                if not (exclude):
                    completepath = self.file_provider().join(path, subpath)
                    if completepath in pathinfos:
                        # print "[%s] : %d v (%s)" % (subpath,pathinfos[completepath].totalArea(),completepath)
                        dirInfo.insertChild(pathinfos[completepath])
                        # print "[%s] : %d ^ (%s)" % (subpath,pathinfos[completepath].totalArea(),completepath)
                        del pathinfos[completepath]

            dirInfo.finalizeLocal()

            if path == self._rootpath:
                self._root = dirInfo
        # print "[%s]" % (pathinfos,)
        return self._root