def _generate ( self ) : doc_count = 0 for fp in self . all_files : for doc in self . _get_docs_for_path ( fp ) : yield doc doc_count += 1 if doc_count >= self . max_docs : return
how to iterate through files in documents in python
Parses a file or directory of files into a set of Document objects .
def _generate(self):
        """Parses a file or directory of files into a set of ``Document`` objects."""
        doc_count = 0
        for fp in self.all_files:
            for doc in self._get_docs_for_path(fp):
                yield doc
                doc_count += 1
                if doc_count >= self.max_docs:
                    return