Xqt has submitted this change. ( 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1193409?usp=email )

Change subject: misspelling.py: Add -page option for single misspelling
......................................................................

misspelling.py: Add -page option for single misspelling

Allow fixing links in pages that link to a specified misspelling
page using the -page argument.
Previously, the bot only handled categories or templates.

Bug: T151540
Change-Id: Ia83f08577ee49d5867689ae945b3280e4ad8f7f6
---
M scripts/misspelling.py
1 file changed, 13 insertions(+), 1 deletion(-)

Approvals:
  Xqt: Verified; Looks good to me, approved
  Matěj Suchánek: Looks good to me, but someone else must approve




diff --git a/scripts/misspelling.py b/scripts/misspelling.py
index e976620..212a169 100755
--- a/scripts/misspelling.py
+++ b/scripts/misspelling.py
@@ -62,11 +62,20 @@

     # Optional: if there is a category, one can use the -start parameter
     misspelling_categories = ('Q8644265', 'Q9195708')
-    update_options = {'start': None}
+    update_options = {'start': None, 'page': None}

     @property
     def generator(self) -> Generator[pywikibot.Page]:
         """Generator to retrieve misspelling pages or misspelling redirects."""
+        # If a single page is specified, yield that page directly
+        if self.opt.page:
+            page = pywikibot.Page(self.site, self.opt.page)
+            if page.exists():
+                yield page
+            else:
+                pywikibot.error(f"Page '{self.opt.page}' does not exist.")
+            return
+
         templates = self.misspelling_templates.get(self.site.sitename)
         categories = [cat for cat in (self.site.page_from_repository(item)
                                       for item in self.misspelling_categories)
@@ -173,6 +182,9 @@
                 'At which page do you want to start?')
         elif opt == 'main':
             options[opt] = True
+        elif opt == 'page':
+            options[opt] = value or pywikibot.input(
+                'Which page do you want to process?')

     bot = MisspellingRobot(**options)
     bot.run()

--
To view, visit 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1193409?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.wikimedia.org/r/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: Ia83f08577ee49d5867689ae945b3280e4ad8f7f6
Gerrit-Change-Number: 1193409
Gerrit-PatchSet: 4
Gerrit-Owner: Tejashxv <[email protected]>
Gerrit-Reviewer: Matěj Suchánek <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
Gerrit-CC: Kavaljeet Singh <[email protected]>
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to