Beispiel #1
0
    def index(self, path, name, parentpath=None, parent=None, isdir=False):
        ''' index a folder and store in tree '''
        if not parent:
            parent = noder.dir_node(name, path, parent)

        cnt = 0
        for (root, dirs, files) in os.walk(path):
            for f in files:
                sub = os.path.join(root, f)
                n = f
                if len(n) > self.MAXLINE:
                    n = f[:self.MAXLINE] + '...'
                Logger.progr('indexing: {:80}'.format(n))
                self.noder.file_node(os.path.basename(f), sub, parent,
                                     parentpath)
                cnt += 1
            for d in dirs:
                base = os.path.basename(d)
                sub = os.path.join(root, d)
                dummy = self.noder.dir_node(base, sub, parent, parentpath)
                _, cnt2 = self.index(sub,
                                     base,
                                     parent=dummy,
                                     parentpath=parentpath)
                cnt += cnt2
            break
        # clean line
        Logger.progr('{:80}'.format(' '))

        return parent, cnt
Beispiel #2
0
 def _log(self, string):
     if self.debug:
         return
     if not string:
         # clean
         Logger.progr('{:80}'.format(' '))
         return
     if len(string) > self.MAXLINE:
         string = string[:self.MAXLINE] + '...'
     Logger.progr('indexing: {:80}'.format(string))