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

Change subject: [fix] Ignore extension check in delinker.py scripts/delinker.py
......................................................................

[fix] Ignore extension check in delinker.py scripts/delinker.py

- add ignore_extension parameter to FilePage initializer to instantiate
  a FilePage object without file extensions check

Bug: T352237
Change-Id: Ic7fe1750113047654c5660ff2de245a0a37279da
---
M pywikibot/page/_filepage.py
M scripts/delinker.py
2 files changed, 16 insertions(+), 9 deletions(-)

Approvals:
  Xqt: Verified; Looks good to me, approved




diff --git a/pywikibot/page/_filepage.py b/pywikibot/page/_filepage.py
index eaed3dd..d91c181 100644
--- a/pywikibot/page/_filepage.py
+++ b/pywikibot/page/_filepage.py
@@ -38,25 +38,33 @@
     Supports the same interface as Page except *ns*; some added methods.
     """
 
-    def __init__(self, source, title: str = '') -> None:
+    def __init__(self, source, title: str = '', *,
+                 ignore_extension: bool = False) -> None:
         """Initializer.

         .. versionchanged:: 8.4
            check for valid extensions.
+        .. versionchanged:: 9.3
+           *ignore_extension* parameter was added

         :param source: the source of the page
         :type source: pywikibot.page.BaseLink (or subclass),
             pywikibot.page.Page (or subclass), or pywikibot.page.Site
         :param title: normalized title of the page; required if source is a
             Site, ignored otherwise
+        :param ignore_extension: prevent extension check
         :raises ValueError: Either the title is not in the file
-            namespace or does not have a valid extension.
+            namespace or does not have a valid extension and
+            *ignore_extension* was not set.
         """
         self._file_revisions = {}  # dictionary to cache File history.
         super().__init__(source, title, 6)
         if self.namespace() != 6:
             raise ValueError(f"'{self.title()}' is not in the file namespace!")

+        if ignore_extension:
+            return
+
         title = self.title(with_ns=False, with_section=False)
         _, sep, extension = title.rpartition('.')
         if not sep or extension.lower() not in self.site.file_extensions:
diff --git a/scripts/delinker.py b/scripts/delinker.py
index cb78714..13513ac 100755
--- a/scripts/delinker.py
+++ b/scripts/delinker.py
@@ -19,12 +19,11 @@
             stops, the last timestamp is written to the settings file and
             the next script call starts there if no `-since` is given.

-.. note:: This sample script is a
-   :class:`ConfigParserBot <bot.ConfigParserBot>`. All
-   settings can be made either by giving option with the command line or
-   with a settings file which is scripts.ini by default. If you don't
-   want the default values you can add any option you want to change to
-   that settings file below the [delinker] section like.
+.. note:: This script is a :class:`ConfigParserBot <bot.ConfigParserBot>`.
+   All settings can be made either by giving option with the command
+   line or with a settings file which is scripts.ini by default. If you
+   don't want the default values you can add any option you want to
+   change to that settings file below the [delinker] section like.

 .. versionadded:: 7.2
    This script is completely rewriten from compat branch.
@@ -89,7 +88,7 @@
     def init_page(self, item) -> pywikibot.page.FilePage:
         """Upcast logevent to FilePage and combine edit summary."""
         self.summary_parameters = dict(item)
-        return pywikibot.FilePage(self.site, item['title'])
+        return pywikibot.FilePage(item.page(), ignore_extension=True)

     def skip_page(self, page) -> bool:
         """Skip pages which neither exists locally nor on shared repository."""

--
To view, visit 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1054503?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: Ic7fe1750113047654c5660ff2de245a0a37279da
Gerrit-Change-Number: 1054503
Gerrit-PatchSet: 4
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: Aram <[email protected]>
Gerrit-Reviewer: D3r1ck01 <[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