jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1340627?usp=email )
Change subject: Normalize image-check settings once per entry
......................................................................
Normalize image-check settings once per entry
Lowercase the find mode before scanning its patterns and reuse it for
both mode comparisons. Also lowercase the imagechanges setting once
before checking its boolean value.
Avoid repeated conversions while preserving case-insensitive matching
and the error for invalid imagechanges settings.
Change-Id: Ib0ef1db72be74638ba856d6d86566b6f60961897
---
M scripts/checkimages.py
1 file changed, 6 insertions(+), 5 deletions(-)
Approvals:
jenkins-bot: Verified
Mahveotm: Looks good to me, approved
diff --git a/scripts/checkimages.py b/scripts/checkimages.py
index 01a7bef..4546088 100755
--- a/scripts/checkimages.py
+++ b/scripts/checkimages.py
@@ -1376,10 +1376,10 @@
find_type = tupla[2]
find = tupla[3]
find_list = self.load(find)
- imagechanges = tupla[4]
- if imagechanges.lower() == 'false':
+ imagechanges = tupla[4].lower()
+ if imagechanges == 'false':
imagestatus = False
- elif imagechanges.lower() == 'true':
+ elif imagechanges == 'true':
imagestatus = True
else:
pywikibot.error('Imagechanges set wrongly!')
@@ -1391,8 +1391,9 @@
head_2 = re.findall(r'\s*== *(.+?) *==\s*', head_2)[0]
text = tupla[7] % self.image_name
mex_catched = tupla[8]
+ find_type = find_type.lower()
for k in find_list:
- if find_type.lower() == 'findonly':
+ if find_type == 'findonly':
search_results = re.findall(fr'{k.lower()}',
image_check_text_lower)
if search_results \
@@ -1405,7 +1406,7 @@
self.summary_used = summary
self.mex_used = mex_catched
break
- elif find_type.lower() == 'find' \
+ elif find_type == 'find' \
and re.search(fr'{k.lower()}',
image_check_text_lower):
self.some_problem = True
--
To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1340627?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: Ib0ef1db72be74638ba856d6d86566b6f60961897
Gerrit-Change-Number: 1340627
Gerrit-PatchSet: 2
Gerrit-Owner: Mahveotm <[email protected]>
Gerrit-Reviewer: Mahveotm <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]