def walk(self):
        """ Generate paths in "self.datapath".
        """
        # FIFO?
        if self._fifo:
            if self._fifo > 1:
                raise RuntimeError("INTERNAL ERROR: FIFO read twice!")
            self._fifo += 1

            # Read paths relative to directory containing the FIFO
            with open(self.datapath, "r") as fifo:
                while True:
                    relpath = fifo.readline().rstrip('\n')
                    if not relpath: # EOF?
                        break
                    self.LOG.debug("Read relative path %r from FIFO..." % (relpath,))
                    yield os.path.join(os.path.dirname(self.datapath), relpath)

            self.LOG.debug("FIFO %r closed!" % (self.datapath,))

        # Directory?
        elif os.path.isdir(self.datapath):
            # Walk the directory tree
            for dirpath, dirnames, filenames in os.walk(self.datapath): #, followlinks=True):
                # Don't scan blacklisted directories
                for bad in dirnames[:]:
                    if any(fnmatch.fnmatch(bad, pattern) for pattern in self.ignore):
                        dirnames.remove(bad)

                # Yield all filenames that aren't blacklisted
                for filename in filenames:
                    if not any(fnmatch.fnmatch(filename, pattern) for pattern in self.ignore):
                        #yield os.path.join(dirpath[len(self.datapath)+1:], filename)
                        yield os.path.join(dirpath, filename)

        # Single file
        else:
            # Yield the filename
            yield self.datapath
def walk ( self ) : if self . _fifo : if self . _fifo > 1 : raise RuntimeError ( "INTERNAL ERROR: FIFO read twice!" ) self . _fifo += 1 with open ( self . datapath , "r" ) as fifo : while True : relpath = fifo . readline ( ) . rstrip ( '\n' ) if not relpath : break self . LOG . debug ( "Read relative path %r from FIFO..." % ( relpath , ) ) yield os . path . join ( os . path . dirname ( self . datapath ) , relpath ) self . LOG . debug ( "FIFO %r closed!" % ( self . datapath , ) ) elif os . path . isdir ( self . datapath ) : for dirpath , dirnames , filenames in os . walk ( self . datapath ) : for bad in dirnames [ : ] : if any ( fnmatch . fnmatch ( bad , pattern ) for pattern in self . ignore ) : dirnames . remove ( bad ) for filename in filenames : if not any ( fnmatch . fnmatch ( filename , pattern ) for pattern in self . ignore ) : yield os . path . join ( dirpath , filename ) else : yield self . datapath
Generate paths in "self.datapath".