Xqt submitted this change.

View Change

Approvals: jenkins-bot: Verified Xqt: Looks good to me, approved
[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(-)

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()



To view, visit change 668080. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: If99c48fdc9e2462160ce31448f37860275984cbc
Gerrit-Change-Number: 668080
Gerrit-PatchSet: 5
Gerrit-Owner: Xqt <info@gno.de>
Gerrit-Reviewer: D3r1ck01 <xsavitar.wiki@aol.com>
Gerrit-Reviewer: DannyS712 <dannys712.wiki@gmail.com>
Gerrit-Reviewer: Xqt <info@gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-CC: JAn Dudík <jan.dudik@gmail.com>
Gerrit-CC: Matěj Suchánek <matejsuchanek97@gmail.com>
Gerrit-MessageType: merged