def search(self, *args, **kwds): for path in Folder.listdir(self.dirname, **kwds): if path.lower().endswith('.pdf'): path = pdf2txt(path) yield [{ 'keyword': term, 'match': match, 'path': path } for term in self.keywords for match in self.get_matches(path) if term in match]