jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1345319?usp=email )
Change subject: checkimages: Reuse formatted template titles
......................................................................
checkimages: Reuse formatted template titles
Format known template titles once per smart_detection call and reuse
them when matching templates from the image description. Previously,
each description template repeated URL formatting and lowercasing for
every known template.
Keep template objects in their original order, including titles that
normalize to the same string. Skip formatting if the description has
no template candidates.
Change-Id: I4c2964e93508c59fdda75a9520fb95e71b389bce
---
M scripts/checkimages.py
1 file changed, 9 insertions(+), 3 deletions(-)
Approvals:
jenkins-bot: Verified
Xqt: Looks good to me, approved
diff --git a/scripts/checkimages.py b/scripts/checkimages.py
index 4546088..2f90ffe 100755
--- a/scripts/checkimages.py
+++ b/scripts/checkimages.py
@@ -1213,13 +1213,19 @@
f'page {self.image}!')
self.all_licenses = []
+ template_titles = []
+ if templates_in_the_image_raw:
+ template_titles = [
+ (template,
+ template.title(as_url=True, with_ns=False).lower())
+ for template in self.licenses_found
+ ]
+
# Found the templates ONLY in the image's description
for template_selected in templates_in_the_image_raw:
tp = pywikibot.Page(self.site, template_selected)
page_title = tp.title(as_url=True, with_ns=False).lower()
- for template_real in self.licenses_found:
- template_title = template_real.title(as_url=True,
- with_ns=False).lower()
+ for template_real, template_title in template_titles:
if page_title == template_title \
and template_real not in self.all_licenses:
self.all_licenses.append(template_real)
--
To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1345319?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: I4c2964e93508c59fdda75a9520fb95e71b389bce
Gerrit-Change-Number: 1345319
Gerrit-PatchSet: 2
Gerrit-Owner: Mahveotm <[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]