jenkins-bot has submitted this change. ( 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1198495?usp=email )

Change subject: IMPR: Improvement for pagefromfile.NoTitleError
......................................................................

IMPR: Improvement for pagefromfile.NoTitleError

- add optional source parameter
- combine parameters to an exception string
- pass exception string to super class
- use exception for error message within PageFromFileReader

Change-Id: I7cb676ca0005b1d65c8c55c24854f1c30f514e99
---
M scripts/pagefromfile.py
1 file changed, 13 insertions(+), 3 deletions(-)

Approvals:
  jenkins-bot: Verified
  Xqt: Looks good to me, approved




diff --git a/scripts/pagefromfile.py b/scripts/pagefromfile.py
index 29bf99a..76bcd91 100755
--- a/scripts/pagefromfile.py
+++ b/scripts/pagefromfile.py
@@ -96,9 +96,19 @@

     """No title found."""

-    def __init__(self, offset) -> None:
-        """Initializer."""
+    def __init__(self, offset: int, source: str | None = None) -> None:
+        """Initializer.
+
+        .. versionchanged:: 10.7
+           *source* was added; a message was passed to Exception super
+           class.
+        """
         self.offset = offset
+        self.source = source
+        message = f'No title found at offset {offset}'
+        if source:
+            message += f' in {source!r}'
+        super().__init__(message)


 class PageFromFileRobot(SingleSiteBot, CurrentPageBot):
@@ -249,7 +259,7 @@
                 break

             except NoTitleError as err:
-                pywikibot.info('\nNo title found - skipping a page.')
+                pywikibot.info('\n{err} - skipping a page.')
                 text = text[err.offset:]
             else:
                 page = pywikibot.Page(self.site, title)

--
To view, visit 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1198495?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: I7cb676ca0005b1d65c8c55c24854f1c30f514e99
Gerrit-Change-Number: 1198495
Gerrit-PatchSet: 3
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to