Mpaa has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/313309

Change subject: unusedfiles.py: do not tag image if already tagged
......................................................................

unusedfiles.py: do not tag image if already tagged

Prevent the bot from tagging the image again if already tagged.

Bug: T145853
Change-Id: I6929593522719336d6f21515ecebba4c577a568f
---
M scripts/unusedfiles.py
1 file changed, 5 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core 
refs/changes/09/313309/1

diff --git a/scripts/unusedfiles.py b/scripts/unusedfiles.py
index 3bb027a..a8aec75 100755
--- a/scripts/unusedfiles.py
+++ b/scripts/unusedfiles.py
@@ -53,6 +53,10 @@
 
         self.template_image = i18n.translate(self.site,
                                              template_to_the_image)
+        self.template_image_page = pywikibot.Page(self.site,
+                                                  self.template_image[2:-2],
+                                                  ns=10)
+
         self.template_user = i18n.translate(self.site,
                                             template_to_the_user)
         self.summary = i18n.twtranslate(self.site, 'unusedfiles-comment')
@@ -71,7 +75,7 @@
         # rather than a local page with the same name as shared media.
         if (image.fileUrl() and not image.fileIsShared() and
                 u'http://' not in image.text):
-            if self.template_image in image.text:
+            if self.template_image_page in image.templates():
                 pywikibot.output(u"%s done already"
                                  % image.title(asLink=True))
                 return

-- 
To view, visit https://gerrit.wikimedia.org/r/313309
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6929593522719336d6f21515ecebba4c577a568f
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Mpaa <mpaa.w...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to