http://www.mediawiki.org/wiki/Special:Code/pywikipedia/10102
Revision: 10102 Author: xqt Date: 2012-04-09 14:58:32 +0000 (Mon, 09 Apr 2012) Log Message: ----------- new ImageGenerator() method (like CategoryGenerator): yields the same pages, but as Image objects instead of Page objects.
Modified Paths: -------------- trunk/pywikipedia/pagegenerators.py
Modified: trunk/pywikipedia/pagegenerators.py =================================================================== --- trunk/pywikipedia/pagegenerators.py 2012-04-09 12:47:22 UTC (rev 10101) +++ trunk/pywikipedia/pagegenerators.py 2012-04-09 14:58:32 UTC (rev 10102) @@ -1153,6 +1153,15 @@ for page in generator: yield catlib.Category(page.site(), page.title())
+def ImageGenerator(generator): + """ + Wraps around another generator. Yields the same pages, but as Image + objects instead of Page objects. Makes sense only if it is ascertained + that only categories are being retrieved. + """ + for page in generator: + yield pywikibot.ImagePage(page.site(), page.title()) + def PageWithTalkPageGenerator(generator): """ Wraps around another generator. Yields the same pages, but for non-talk
pywikipedia-svn@lists.wikimedia.org