Xqt has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/668080 )
Change subject: [IMPR] Update option handing for solve_disambiguation.py ......................................................................
[IMPR] Update option handing for solve_disambiguation.py
Update option handing to use the new DisambiguationRobot interface
Change-Id: If99c48fdc9e2462160ce31448f37860275984cbc --- M scripts/solve_disambiguation.py 1 file changed, 9 insertions(+), 25 deletions(-)
Approvals: jenkins-bot: Verified Xqt: Looks good to me, approved
diff --git a/scripts/solve_disambiguation.py b/scripts/solve_disambiguation.py index 91c3c17..6bfa203 100755 --- a/scripts/solve_disambiguation.py +++ b/scripts/solve_disambiguation.py @@ -1377,19 +1377,9 @@
@param args: command line arguments """ - # the option that's always selected when the bot wonders what to do with - # a link. If it's None, the user is prompted (default behaviour). - always = None + options = {} alternatives = [] - getAlternatives = True - dnSkip = False generator = None - primary = False - first_only = False - main_only = False - - # For sorting the linked pages, case can be ignored - minimum = 0
local_args = pywikibot.handle_args(args) site = pywikibot.Site() @@ -1400,12 +1390,12 @@ for argument in local_args: arg, _, value = argument.partition(':') if arg == '-primary': - primary = True + options['primary'] = True if value: - getAlternatives = False + options['just'] = False alternatives.append(value) elif arg == '-always': - always = value + options['always'] = value or None elif arg == '-pos': if not value: continue @@ -1421,15 +1411,11 @@ automatic_quit=False): alternatives.append(page.title()) elif arg == '-just': - getAlternatives = False - elif arg == '-dnskip': - dnSkip = True - elif arg == '-main': - main_only = True - elif arg == '-first': - first_only = True + options['just'] = False + elif arg in ('-dnskip', '-main', '-first'): + options[arg[1:]] = True elif arg == '-min': - minimum = int(value) + options['min'] = int(value or 0) elif arg == '-start': try: generator = pagegenerators.CategorizedPageGenerator( @@ -1447,9 +1433,7 @@ pywikibot.bot.suggest_help(missing_generator=True) return
- bot = DisambiguationRobot(always, alternatives, getAlternatives, dnSkip, - generator, primary, main_only, first_only, - minimum=minimum) + bot = DisambiguationRobot(generator=generator, pos=alternatives, **options) bot.run()