Revision: 5192 Author: russblau Date: 2008-04-07 22:13:44 +0000 (Mon, 07 Apr 2008)
Log Message: ----------- code cleanup
Modified Paths: -------------- trunk/pywikipedia/pagegenerators.py
Modified: trunk/pywikipedia/pagegenerators.py =================================================================== --- trunk/pywikipedia/pagegenerators.py 2008-04-07 17:04:34 UTC (rev 5191) +++ trunk/pywikipedia/pagegenerators.py 2008-04-07 22:13:44 UTC (rev 5192) @@ -708,30 +708,26 @@
def generator(self): try: - try: - # this array will contain up to pageNumber pages and will be flushed - # after these pages have been preloaded and yielded. - somePages = [] - for page in self.wrapped_gen: - if self.finished.isSet(): - return - somePages.append(page) - # We don't want to load too many pages at once using XML export. - # We only get a maximum number at a time. - if len(somePages) >= self.pageNumber: - for loaded_page in self.preload(somePages): - yield loaded_page - somePages = [] - if somePages: - # wrapped generator is exhausted but some pages still unloaded - # preload remaining pages + # this array will contain up to pageNumber pages and will be flushed + # after these pages have been preloaded and yielded. + somePages = [] + for page in self.wrapped_gen: +## if self.finished.isSet(): +## return + somePages.append(page) + # We don't want to load too many pages at once using XML export. + # We only get a maximum number at a time. + if len(somePages) >= self.pageNumber: for loaded_page in self.preload(somePages): yield loaded_page - except Exception, e: - wikipedia.output(unicode(e)) - finally: - if hasattr(self.wrapped_gen, "stop"): - self.wrapped_gen.stop() + somePages = [] + if somePages: + # wrapped generator is exhausted but some pages still unloaded + # preload remaining pages + for loaded_page in self.preload(somePages): + yield loaded_page + except Exception, e: + wikipedia.output(unicode(e))
def preload(self, page_list): try: