jenkins-bot has submitted this change and it was merged.
Change subject: add ImageGenerator and UnCategorizedTemplateGenerator
......................................................................
add ImageGenerator and UnCategorizedTemplateGenerator
ported from compat branch
APISite.uncategorizedtemplates() was available since
https://www.mediawiki.org/wiki/Special:Code/pywikipedia/9843
but had no corresponding pagegenerators
renamed UnCategorizedTemplatesGenerator
into UnCategorizedTemplateGenerator
for consistency reasons, as:
* UnCategorizedCategoryGenerator
* UnCategorizedImageGenerator
* UnCategorizedPageGenerator
bug: 55007
Change-Id: I961310f6b3f13f1ac3880857e0f454576a0cbce6
---
M pywikibot/pagegenerators.py
1 file changed, 17 insertions(+), 0 deletions(-)
Approvals:
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/pagegenerators.py b/pywikibot/pagegenerators.py
index b33d3a3..ff64ab8 100644
--- a/pywikibot/pagegenerators.py
+++ b/pywikibot/pagegenerators.py
@@ -846,6 +846,16 @@
yield pywikibot.Category(page)
+def ImageGenerator(generator):
+ """
+ Wraps around another generator. Yields the same pages, but as ImagePage
+ objects instead of Page objects. Makes sense only if it is ascertained
+ that only images are being retrieved.
+ """
+ for page in generator:
+ yield pywikibot.ImagePage(page)
+
+
def PageWithTalkPageGenerator(generator):
"""Yield pages and associated talk pages from another generator.
@@ -983,6 +993,13 @@
yield page
+def UnCategorizedTemplateGenerator(total=100, site=None):
+ if site is None:
+ site = pywikibot.Site()
+ for page in site.uncategorizedtemplates(total=total):
+ yield page
+
+
@deprecate_arg("number", "total")
@deprecate_arg("repeat", None)
def LonelyPagesPageGenerator(total=100, site=None):
--
To view, visit
https://gerrit.wikimedia.org/r/126934
To unsubscribe, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I961310f6b3f13f1ac3880857e0f454576a0cbce6
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Ricordisamoa <ricordisamoa(a)live.it>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: Ricordisamoa <ricordisamoa(a)live.it>
Gerrit-Reviewer: jenkins-bot <>