jenkins-bot has submitted this change and it was merged.
Change subject: Bug 67249: allow filtering of newpages by ns
......................................................................
Bug 67249: allow filtering of newpages by ns
Partial workaround:
If namespace/ns parameters are specified before -newpages, provided
namespace values are used, otherwise default is ns=0.
Same logic applied to RecentChangesPageGenerator to improve efficiency
of the query, if wanted.
Change-Id: I20a4b04bb8f30cd750d43856a89cdf471898f84e
---
M pywikibot/pagegenerators.py
1 file changed, 14 insertions(+), 5 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/pagegenerators.py b/pywikibot/pagegenerators.py
index b525839..fa55fdf 100644
--- a/pywikibot/pagegenerators.py
+++ b/pywikibot/pagegenerators.py
@@ -72,8 +72,12 @@
across all namespaces.
-namespace Filter the page generator to only yield pages in the
--ns specified namespaces. Separate multiple namespace
+-ns specified namespaces. Separate multiple namespace
numbers with commas. Example "-ns:0,2,4"
+ If used with -newpages, -namepace/ns must be provided
+ before -newpages.
+ If used with -recentchanges, efficiency is improved if
+ -namepace/ns is provided before -recentchanges.
-interwiki Work on the given page and all equivalent pages in other
languages. This can, for example, be used to fight
@@ -349,10 +353,11 @@
else:
gen = RandomPageGenerator(total=int(arg[8:]))
elif arg.startswith('-recentchanges'):
+ namespaces = [int(n) for n in self.namespaces] or None
if len(arg) >= 15:
- gen = RecentChangesPageGenerator(total=int(arg[15:]))
+ gen = RecentChangesPageGenerator(namespaces=namespaces,
total=int(arg[15:]))
else:
- gen = RecentChangesPageGenerator(total=60)
+ gen = RecentChangesPageGenerator(namespaces=namespaces, total=60)
gen = DuplicateFilterPageGenerator(gen)
elif arg.startswith('-file'):
textfilename = arg[6:]
@@ -470,10 +475,14 @@
u'How many images do you want to load?')
gen = NewimagesPageGenerator(total=int(limit))
elif arg.startswith('-newpages'):
+ # partial workaround for bug 67249
+ # to use -namespace/ns with -newpages, -ns must be given before -newpages
+ # otherwise default namespace is 0
+ namespaces = [int(n) for n in self.namespaces] or 0
if len(arg) >= 10:
- gen = NewpagesPageGenerator(total=int(arg[10:]))
+ gen = NewpagesPageGenerator(namespaces=namespaces, total=int(arg[10:]))
else:
- gen = NewpagesPageGenerator(total=60)
+ gen = NewpagesPageGenerator(namespaces=namespaces, total=60)
elif arg.startswith('-imagesused'):
imagelinkstitle = arg[len('-imagesused:'):]
if not imagelinkstitle:
--
To view, visit
https://gerrit.wikimedia.org/r/151307
To unsubscribe, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I20a4b04bb8f30cd750d43856a89cdf471898f84e
Gerrit-PatchSet: 3
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: jenkins-bot <>