jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/790720 )
Change subject: [IMPR] Prioritize -namespaces options in pg.handle_args
......................................................................
[IMPR] Prioritize -namespaces options in pg.handle_args
Prioritize -namespaces options to solve problems with several
generators like -newpages/-random/-randomredirect/-linter.
pagegenerators.handle_arg should be deprecated and replaced by
pagegenerators.handle_args to solve these issues completely.
Bug: T222519
Change-Id: Ifdb222f4725d2e1c74f9e97373cc5dfdf2416670
---
M pywikibot/pagegenerators.py
1 file changed, 10 insertions(+), 3 deletions(-)
Approvals:
Matěj Suchánek: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/pagegenerators.py b/pywikibot/pagegenerators.py
index 796cecf..002ca17 100644
--- a/pywikibot/pagegenerators.py
+++ b/pywikibot/pagegenerators.py
@@ -365,9 +365,9 @@
-ns:not:2,3
-ns:not:Help,File
- If used with -newpages/-random/-randomredirect/linter
+ If used with -newpages/-random/-randomredirect/-linter
generators, -namespace/ns must be provided before
- -newpages/-random/-randomredirect/linter.
+ -newpages/-random/-randomredirect/-linter.
If used with -recentchanges generator, efficiency is
improved if -namespace is provided before -recentchanges.
@@ -1267,8 +1267,15 @@
"""Handle command line arguments and return the rest as a list.
.. versionadded:: 6.0
+ .. versionchanged:: 7.3
+ Prioritize -namespaces options to solve problems with several
+ generators like -newpages/-random/-randomredirect/-linter
"""
- return [arg for arg in args if not self.handle_arg(arg)]
+ ordered_args = [arg for arg in args
+ if arg.startswith(('-ns', '-namespace'))]
+ ordered_args += [arg for arg in args
+ if not arg.startswith(('-ns', '-namespace'))]
+ return [arg for arg in ordered_args if not self.handle_arg(arg)]
def handle_arg(self, arg: str) -> bool:
"""Parse one argument at a time.
--
To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/790720
To unsubscribe, or for help writing mail filters, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: Ifdb222f4725d2e1c74f9e97373cc5dfdf2416670
Gerrit-Change-Number: 790720
Gerrit-PatchSet: 4
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: Matěj Suchánek <matejsuchanek97(a)gmail.com>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged