jenkins-bot submitted this change.
[IMPR] Improvements for misspelling.py
Prepare misspelling.py for importing DisambigBotBase from specialbots
Patch detached 51c3b50
Bug: T266997
Change-Id: I36326e8e9287b355cfeb474f4f0f3edadbe4700d
---
M scripts/misspelling.py
1 file changed, 12 insertions(+), 13 deletions(-)
diff --git a/scripts/misspelling.py b/scripts/misspelling.py
index af6029a..773bace 100755
--- a/scripts/misspelling.py
+++ b/scripts/misspelling.py
@@ -26,7 +26,7 @@
# Distributed under the terms of the MIT license.
#
from itertools import chain
-from typing import Generator
+from typing import Generator, Tuple
import pywikibot
@@ -34,7 +34,7 @@
from pywikibot.bot import SingleSiteBot
from pywikibot.tools.formatter import color_format
-from scripts.solve_disambiguation import DisambiguationRobot
+from scripts.solve_disambiguation import DisambiguationRobot as DisambigBotBase
HELP_MSG = """\n
misspelling.py does not support site {site}.
@@ -46,7 +46,7 @@
these misspellings.\n"""
-class MisspellingRobot(DisambiguationRobot):
+class MisspellingRobot(DisambigBotBase):
"""Spelling bot."""
@@ -117,19 +117,19 @@
preloadingGen = pagegenerators.PreloadingGenerator(generator)
yield from preloadingGen
- def findAlternatives(self, disambPage) -> bool:
+ def findAlternatives(self, page) -> bool:
"""
Append link target to a list of alternative links.
- Overrides the DisambiguationRobot method.
+ Overrides the DisambigBotBase method.
@return: True if alternate link was appended
"""
- if disambPage.isRedirectPage():
- self.alternatives.append(disambPage.getRedirectTarget().title())
+ if page.isRedirectPage():
+ self.alternatives.append(page.getRedirectTarget().title())
return True
- sitename = disambPage.site.sitename
+ sitename = page.site.sitename
templates = self.misspelling_templates.get(sitename)
if templates is None:
return False
@@ -137,7 +137,7 @@
if isinstance(templates, str):
templates = (templates, )
- for template, params in disambPage.templatesWithParams():
+ for template, params in page.templatesWithParams():
if template.title(with_ns=False) in templates:
# The correct spelling is in the last parameter.
correct_spelling = params[-1]
@@ -154,7 +154,7 @@
return True
return False
- def setSummaryMessage(self, disambPage, *args, **kwargs) -> None:
+ def setSummaryMessage(self, page, *args, **kwargs) -> None:
"""
Setup the summary message.
@@ -163,17 +163,16 @@
# TODO: setSummaryMessage() in solve_disambiguation now has parameters
# new_targets and unlink. Make use of these here.
self.comment = i18n.twtranslate(self.site, 'misspelling-fixing',
- {'page': disambPage.title()})
+ {'page': page.title()})
-def main(*args) -> None:
+def main(*args: Tuple[str, ...]) -> None:
"""
Process command line arguments and invoke bot.
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: str
"""
options = {}
for arg in pywikibot.handle_args(args):
To view, visit change 638022. To unsubscribe, or for help writing mail filters, visit settings.