XXN has uploaded a new change for review.
https://gerrit.wikimedia.org/r/321089
Change subject: New page generators (T150222), typos.
......................................................................
New page generators (T150222), typos.
Added pagegenerators:
-wantedpages
-wantedfiles
-wantedcategories
-wantedtemplates
Bug: T150222
Change-Id: I7d5cba11c2534b8ff90d10205cc399a06ce83590
---
M pywikibot/pagegenerators.py
M pywikibot/site.py
2 files changed, 110 insertions(+), 20 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core
refs/changes/89/321089/2
diff --git a/pywikibot/pagegenerators.py b/pywikibot/pagegenerators.py
index e60c98f..b4c446a 100644
--- a/pywikibot/pagegenerators.py
+++ b/pywikibot/pagegenerators.py
@@ -246,6 +246,18 @@
-usercontribs Work on all articles that were edited by a certain user.
(Example : -usercontribs:DumZiBoT)
+-wantedpages Work on pages that are linked, but does not exist;
+ may be given as "-wantedpages:n"
+
+-wantedcategories Work on categories that are used, but does not exist;
+ may be given as "-wantedcategories:n"
+
+-wantedfiles Work on files that are used, but does not exist;
+ may be given as "-wantedfiles:n"
+
+-wantedtemplates Work on templates that are used, but does not exist;
+ may be given as "-wantedtemplates:n"
+
-weblink Work on all articles that contain an external link to
a given URL; may be given as "-weblink:url"
@@ -655,6 +667,14 @@
gen = FileLinksGenerator(page)
elif arg == '-unusedfiles':
gen = UnusedFilesGenerator(total=intNone(value), site=self.site)
+ elif arg == '-wantedpages':
+ gen = WantedPagesPageGenerator(total=intNone(value),
site=self.site)
+ elif arg == '-wantedfiles':
+ gen = WantedFilesGenerator(total=intNone(value), site=self.site)
+ elif arg == '-wantedcategories':
+ gen = WantedCategoriesGenerator(total=intNone(value),
site=self.site)
+ elif arg == '-wantedtemplates':
+ gen = WantedTemplatesGenerator(total=intNone(value),
site=self.site)
elif arg == '-lonelypages':
gen = LonelyPagesPageGenerator(total=intNone(value),
site=self.site)
@@ -958,7 +978,7 @@
If includeredirects is False, redirects are not included. If
includeredirects equals the string 'only', only redirects are added.
- @param total: Maxmum number of pages to retrieve in total
+ @param total: Maximum number of pages to retrieve in total
@type total: int
@param content: If True, load current version of each page (default False)
@param site: Site for generator results.
@@ -1363,7 +1383,7 @@
total=None, _filter_unique=filter_unique):
"""Yield unique pages edited by user:username.
- @param total: Maxmum number of pages to retrieve in total
+ @param total: Maximum number of pages to retrieve in total
@type total: int
@param namespaces: list of namespace numbers to fetch contribs from
@type namespaces: list of int
@@ -1953,7 +1973,7 @@
"""
New file generator.
- @param total: Maxmum number of pages to retrieve in total
+ @param total: Maximum number of pages to retrieve in total
@type total: int
@param site: Site for generator results.
@type site: L{pywikibot.site.BaseSite}
@@ -2029,7 +2049,7 @@
"""
Unused files generator.
- @param total: Maxmum number of pages to retrieve in total
+ @param total: Maximum number of pages to retrieve in total
@type total: int
@param site: Site for generator results.
@type site: L{pywikibot.site.BaseSite}
@@ -2045,7 +2065,7 @@
"""
Page lacking interwikis generator.
- @param total: Maxmum number of pages to retrieve in total
+ @param total: Maximum number of pages to retrieve in total
@param site: Site for generator results.
@type site: L{pywikibot.site.BaseSite}
"""
@@ -2060,7 +2080,7 @@
"""
Uncategorized category generator.
- @param total: Maxmum number of pages to retrieve in total
+ @param total: Maximum number of pages to retrieve in total
@type total: int
@param site: Site for generator results.
@type site: L{pywikibot.site.BaseSite}
@@ -2076,7 +2096,7 @@
"""
Uncategorized file generator.
- @param total: Maxmum number of pages to retrieve in total
+ @param total: Maximum number of pages to retrieve in total
@type total: int
@param site: Site for generator results.
@type site: L{pywikibot.site.BaseSite}
@@ -2092,7 +2112,7 @@
"""
Uncategorized page generator.
- @param total: Maxmum number of pages to retrieve in total
+ @param total: Maximum number of pages to retrieve in total
@type total: int
@param site: Site for generator results.
@type site: L{pywikibot.site.BaseSite}
@@ -2108,7 +2128,7 @@
"""
Uncategorized template generator.
- @param total: Maxmum number of pages to retrieve in total
+ @param total: Maximum number of pages to retrieve in total
@type total: int
@param site: Site for generator results.
@type site: L{pywikibot.site.BaseSite}
@@ -2124,7 +2144,7 @@
"""
Lonely page generator.
- @param total: Maxmum number of pages to retrieve in total
+ @param total: Maximum number of pages to retrieve in total
@type total: int
@param site: Site for generator results.
@type site: L{pywikibot.site.BaseSite}
@@ -2140,7 +2160,7 @@
"""
Unwatched page generator.
- @param total: Maxmum number of pages to retrieve in total
+ @param total: Maximum number of pages to retrieve in total
@type total: int
@param site: Site for generator results.
@type site: L{pywikibot.site.BaseSite}
@@ -2155,7 +2175,7 @@
"""
Wanted page generator.
- @param total: Maxmum number of pages to retrieve in total
+ @param total: Maximum number of pages to retrieve in total
@type total: int
@param site: Site for generator results.
@type site: L{pywikibot.site.BaseSite}
@@ -2166,12 +2186,57 @@
yield page
+def WantedCategoriesGenerator(total=100, site=None):
+ """
+ Wanted categories generator.
+
+ @param total: Maximum number of pages to retrieve in total
+ @type total: int
+ @param site: Site for generator results.
+ @type site: L{pywikibot.site.BaseSite}
+ """
+ if site is None:
+ site = pywikibot.Site()
+ for page in site.wantedcategories(total=total):
+ yield page
+
+
+def WantedTemplatesGenerator(total=100, site=None):
+ """
+ Wanted templates generator.
+
+ @param total: Maximum number of pages to retrieve in total
+ @type total: int
+ @param site: Site for generator results.
+ @type site: L{pywikibot.site.BaseSite}
+ """
+ if site is None:
+ site = pywikibot.Site()
+ for page in site.wantedtemplates(total=total):
+ yield page
+
+
+def WantedFilesGenerator(total=100, site=None):
+ """
+ Wanted files generator.
+
+ @param total: Maximum number of pages to retrieve in total
+ @type total: int
+ @param site: Site for generator results.
+ @type site: L{pywikibot.site.BaseSite}
+ """
+ if site is None:
+ site = pywikibot.Site()
+ for page in site.wantedfiles(total=total):
+ yield pywikibot.FilePage(page.site, page.title())
+
+
@deprecated_args(number="total", repeat=None)
def AncientPagesPageGenerator(total=100, site=None):
"""
Ancient page generator.
- @param total: Maxmum number of pages to retrieve in total
+ @param total: Maximum number of pages to retrieve in total
@type total: int
@param site: Site for generator results.
@type site: L{pywikibot.site.BaseSite}
@@ -2187,7 +2252,7 @@
"""
Dead-end page generator.
- @param total: Maxmum number of pages to retrieve in total
+ @param total: Maximum number of pages to retrieve in total
@type total: int
@param site: Site for generator results.
@type site: L{pywikibot.site.BaseSite}
@@ -2203,7 +2268,7 @@
"""
Long page generator.
- @param total: Maxmum number of pages to retrieve in total
+ @param total: Maximum number of pages to retrieve in total
@type total: int
@param site: Site for generator results.
@type site: L{pywikibot.site.BaseSite}
@@ -2219,7 +2284,7 @@
"""
Short page generator.
- @param total: Maxmum number of pages to retrieve in total
+ @param total: Maximum number of pages to retrieve in total
@type total: int
@param site: Site for generator results.
@type site: L{pywikibot.site.BaseSite}
@@ -2235,7 +2300,7 @@
"""
Random page generator.
- @param total: Maxmum number of pages to retrieve in total
+ @param total: Maximum number of pages to retrieve in total
@type total: int
@param site: Site for generator results.
@type site: L{pywikibot.site.BaseSite}
@@ -2251,7 +2316,7 @@
"""
Random redirect generator.
- @param total: Maxmum number of pages to retrieve in total
+ @param total: Maximum number of pages to retrieve in total
@type total: int
@param site: Site for generator results.
@type site: L{pywikibot.site.BaseSite}
@@ -2274,7 +2339,7 @@
@type url: str
@param namespaces: list of namespace numbers to fetch contribs from
@type namespaces: list of int
- @param total: Maxmum number of pages to retrieve in total
+ @param total: Maximum number of pages to retrieve in total
@type total: int
@param site: Site for generator results.
@type site: L{pywikibot.site.BaseSite}
@@ -2290,7 +2355,7 @@
"""
Yield pages from the MediaWiki internal search engine.
- @param total: Maxmum number of pages to retrieve in total
+ @param total: Maximum number of pages to retrieve in total
@type total: int
@param site: Site for generator results.
@type site: L{pywikibot.site.BaseSite}
diff --git a/pywikibot/site.py b/pywikibot/site.py
index 780b48b..c77b55d 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -6383,6 +6383,31 @@
return wcgen
+ @deprecated_args(step=None)
+ def wantedfiles(self, step=None, total=None):
+ """Yield Pages from Special:Wantedfiles.
+
+ @param step: request batch size
+ @param total: number of pages to return
+ """
+ wfgen = self._generator(api.PageGenerator,
+ type_arg="querypage", gqppage="Wantedfiles",
+ step=step, total=total)
+ return wfgen
+
+ @deprecated_args(step=None)
+ def wantedtemplates(self, step=None, total=None):
+ """Yield Pages from Special:Wantedtemplates.
+
+ @param step: request batch size
+ @param total: number of pages to return
+ """
+ wtgen = self._generator(api.PageGenerator,
+ type_arg="querypage",
gqppage="Wantedtemplates",
+ step=step, total=total)
+
+ return wtgen
+
@deprecated_args(number='total', step=None, repeat=None)
def uncategorizedcategories(self, total=None):
"""Yield Categories from Special:Uncategorizedcategories.
--
To view, visit https://gerrit.wikimedia.org/r/321089
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I7d5cba11c2534b8ff90d10205cc399a06ce83590
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XXN <[email protected]>
Gerrit-Reviewer: XZise <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits