jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/904875 )
Change subject: [bugfix] Fix -namespace usage if RedirectGenerator is used ...................................................................... [bugfix] Fix -namespace usage if RedirectGenerator is used Only use pagegenerators' namespace filter if RedirectGenerator is used with -xml or -fullscan option or 'both' action. The later is like -fullscan but with broken and double action. Also show a warning if -fullscan is used together with 'both' action Bug: T331243 Change-Id: Ieffe10248a75877ee79d637bd35ad1585a17684c --- M scripts/redirect.py 1 file changed, 31 insertions(+), 5 deletions(-) Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified diff --git a/scripts/redirect.py b/scripts/redirect.py index 45d138e..a4dadd7 100755 --- a/scripts/redirect.py +++ b/scripts/redirect.py @@ -30,7 +30,7 @@ "-xml:filename.xml". Cannot be used with -fullscan or -moves. -fullscan Retrieve redirect pages from live wiki, not from a special page - Cannot be used with -xml. + Cannot be used with -xml or 'both' action. -moves Use the page move log to find double-redirect candidates. Only works with action "double", does not work with -xml. @@ -66,12 +66,13 @@ ¶ms; """ # -# (C) Pywikibot team, 2004-2022 +# (C) Pywikibot team, 2004-2023 # # Distributed under the terms of the MIT license. # import datetime from contextlib import suppress +from textwrap import fill from typing import Any, Generator, Optional, Union import pywikibot @@ -723,7 +724,12 @@ problem = 'You can only use one of {} options.'.format( ' or '.join(source)) if len(source) > 1 else '' - if suggest_help(additional_text=problem, + + if action == 'both' and '-fullscan' in source: + problem += (' You can only use either -fullscan together with ' + "broken/double action or 'both' action") + + if suggest_help(additional_text=fill(problem), unknown_parameters=unknown, missing_action=not action): return @@ -733,8 +739,12 @@ if gen_factory.namespaces: gen_options['namespaces'] = gen_factory.namespaces gen = RedirectGenerator(action, **gen_options) - options['generator'] = gen_factory.getCombinedGenerator(gen=gen) - bot = RedirectRobot(action, **options) + + if gen_factory.gens \ + or action != 'both' and source not in ('-fullscan', '-xml'): + gen = gen_factory.getCombinedGenerator(gen=gen) + + bot = RedirectRobot(action, generator=gen, **options) bot.run() -- To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/904875 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: Ieffe10248a75877ee79d637bd35ad1585a17684c Gerrit-Change-Number: 904875 Gerrit-PatchSet: 1 Gerrit-Owner: Xqt <i...@gno.de> Gerrit-Reviewer: D3r1ck01 <xsavitar.w...@aol.com> Gerrit-Reviewer: Xqt <i...@gno.de> Gerrit-Reviewer: jenkins-bot Gerrit-MessageType: merged
_______________________________________________ Pywikibot-commits mailing list -- pywikibot-commits@lists.wikimedia.org To unsubscribe send an email to pywikibot-commits-le...@lists.wikimedia.org