jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1062743?usp=email )
Change subject: unusedfiles: remove Flow support
......................................................................
unusedfiles: remove Flow support
flow support did never work with template substitution.
Anyway flow support is to be dropped and there is no need to fix it.
Flow talk page is only found in urwiki recently
Bug: T372477
Change-Id: Icf51219ff7125ea3298f3f012a2540ec79aa3173
---
M scripts/unusedfiles.py
1 file changed, 30 insertions(+), 31 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
Meno25: Looks good to me, but someone else must approve
diff --git a/scripts/unusedfiles.py b/scripts/unusedfiles.py
index bf831b3..c424b82 100755
--- a/scripts/unusedfiles.py
+++ b/scripts/unusedfiles.py
@@ -18,7 +18,7 @@
-usertemplate: Use a custom template to warn the uploader.
"""
#
-# (C) Pywikibot team, 2007-2022
+# (C) Pywikibot team, 2007-2024
#
# Distributed under the terms of the MIT license.
#
@@ -35,7 +35,6 @@
SingleSiteBot,
)
from pywikibot.exceptions import Error, NoPageError, TranslationError
-from pywikibot.flow import Board
template_to_the_image = {
@@ -108,30 +107,39 @@
f'This script is not localized for {self.site} site;\n'
'try using -filetemplate:<template name>.')
+ def skip_page(self, image: pywikibot.page.FilePage) -> bool:
+ """Skip processing on repository images or if image is already tagged.
+
+ Use get_file_url() and file_is_shared() to confirm it is local
+ media rather than a local page with the same name as shared
+ media.
+ """
+ if not image.get_file_url() or image.file_is_shared() \
+ or 'http://' in image.text:
+ return True
+
+ if self.opt.filetemplate in image.text:
+ pywikibot.info(f'{image} done already')
+ return True
+
+ return super().skip_page(image)
+
def treat(self, image) -> None:
"""Process one image page."""
- # Use get_file_url() and file_is_shared() to confirm it is local media
- # rather than a local page with the same name as shared media.
- if (image.get_file_url() and not image.file_is_shared()
- and 'http://' not in image.text):
- if self.opt.filetemplate in image.text:
- pywikibot.info(f'{image} done already')
- return
+ self.append_text(image, '\n\n' + self.opt.filetemplate)
- self.append_text(image, '\n\n' + self.opt.filetemplate)
- if self.opt.nouserwarning:
- return
+ if self.opt.nouserwarning:
+ return
- uploader = image.oldest_file_info.user
- user = pywikibot.User(image.site, uploader)
- usertalkpage = user.getUserTalkPage()
- template2uploader = self.opt.usertemplate \
- % {'title': image.title()}
- msg2uploader = self.site.expand_text(template2uploader)
- if usertalkpage.is_flow_page():
- self.post_to_flow_board(usertalkpage, msg2uploader)
- else:
- self.append_text(usertalkpage, '\n\n' + msg2uploader + ' ~~~~')
+ uploader = image.oldest_file_info.user
+ user = pywikibot.User(image.site, uploader)
+ usertalkpage = user.getUserTalkPage()
+ msg2uploader = self.opt.usertemplate % {'title': image.title()}
+ if usertalkpage.is_flow_page():
+ pywikibot.warning(f'Unsupported Flow talkpage {usertalkpage};'
+ '\n uploader cannot be informed.')
+ else:
+ self.append_text(usertalkpage, '\n\n' + msg2uploader + ' ~~~~')
def append_text(self, page, apptext):
"""Append apptext to the page."""
@@ -149,15 +157,6 @@
self.current_page = page
self.put_current(text)
- @staticmethod
- def post_to_flow_board(page, post) -> None:
- """Post message as a Flow topic."""
- board = Board(page)
- header, rest = post.split('\n', 1)
- title = header.strip('=')
- content = rest.lstrip()
- board.new_topic(title, content)
-
def main(*args: str) -> None:
"""
--
To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1062743?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: Icf51219ff7125ea3298f3f012a2540ec79aa3173
Gerrit-Change-Number: 1062743
Gerrit-PatchSet: 3
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: Aram <[email protected]>
Gerrit-Reviewer: D3r1ck01 <[email protected]>
Gerrit-Reviewer: Meno25 <[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]