jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1328322?usp=email )
Change subject: checkimages: Use search for boolean regex checks
......................................................................
checkimages: Use search for boolean regex checks
Stop regex checks at the first match when only truthiness matters.
Check the site code before running the Italian-only filename regex.
Change-Id: I1ecb23bab97c0b2af681206f995097f8790c4e32
---
M scripts/checkimages.py
1 file changed, 8 insertions(+), 9 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
JJMC89: Looks good to me, approved
diff --git a/scripts/checkimages.py b/scripts/checkimages.py
index 4689414..ee58463 100755
--- a/scripts/checkimages.py
+++ b/scripts/checkimages.py
@@ -839,8 +839,8 @@
# project.
return False
- if re.findall(r'\bstemma\b',
- self.image_name.lower()) and self.site.code == 'it':
+ if self.site.code == 'it' and re.search(
+ r'\bstemma\b', self.image_name.lower()):
pywikibot.info(f"{self.image_name} has 'stemma' inside, means "
f"that it's ok.")
return True
@@ -922,8 +922,8 @@
except NoPageError:
continue
- if not (re.findall(dup_regex, dup_page_text)
- or re.findall(dup_regex, older_page_text)):
+ if not (re.search(dup_regex, dup_page_text)
+ or re.search(dup_regex, older_page_text)):
pywikibot.info(
f'{dup_page} is a duplicate and has to be tagged...')
images_to_tag_list.append(dup_page.title())
@@ -1205,7 +1205,7 @@
if not self.licenses_found and templates_in_the_image_raw:
# {{nameTemplate|something <- this is not a template, be sure
# that we haven't catch something like that.
- licenses_test = regex_are_licenses.findall(
+ licenses_test = regex_are_licenses.search(
self.image_check_text)
if not self.licenses_found and licenses_test:
raise Error(
@@ -1361,8 +1361,7 @@
regex_pattern = re.compile(
r'\{\{(?:template)?%s ?(?:\||\r?\n|\}|<|/) ?'
% i.split('{{')[1].replace(' ', '[ _]'), re.IGNORECASE)
- result = regex_pattern.findall(self.image_check_text)
- if result:
+ if regex_pattern.search(self.image_check_text):
return True
elif i.lower() in self.image_check_text:
return True
@@ -1407,8 +1406,8 @@
self.mex_used = mex_catched
break
elif find_type.lower() == 'find' \
- and re.findall(fr'{k.lower()}',
- image_check_text_lower):
+ and re.search(fr'{k.lower()}',
+ image_check_text_lower):
self.some_problem = True
self.text_used = text
self.head_used = head_2
--
To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1328322?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: I1ecb23bab97c0b2af681206f995097f8790c4e32
Gerrit-Change-Number: 1328322
Gerrit-PatchSet: 3
Gerrit-Owner: Mahveotm <[email protected]>
Gerrit-Reviewer: JJMC89 <[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]