jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/463249 )
Change subject: scripts/maintenance/diff_checker.py: Fix a bug in detecting "" as error
......................................................................
scripts/maintenance/diff_checker.py: Fix a bug in detecting "" as error
Single-quoted empty strings are preferred to double-quotes ones, but
diff_checker did not detect such cases because the ending quotation
marks were being detected as part of the starting quotation marks.
STRING_MATCH: Require at list one character after the starting quotation mark.
Change-Id: Id215527268c286d7f228dbef0e030a93843e9bdf
---
M scripts/maintenance/diff_checker.py
1 file changed, 1 insertion(+), 1 deletion(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/maintenance/diff_checker.py b/scripts/maintenance/diff_checker.py
index 608f501..1bc2727 100644
--- a/scripts/maintenance/diff_checker.py
+++ b/scripts/maintenance/diff_checker.py
@@ -46,7 +46,7 @@
IGNORABLE_LONG_LINE = re_compile(r'\s*(# )?<?https?://\S+>?$').match
STRING_MATCH = re_compile(
- r'(?P<prefix>[bfru]*)?(?P<quote>\'+|"+)', IGNORECASE,
+ r'(?P<prefix>[bfru]*)?(?P<quote>\'+|"+).', IGNORECASE,
).match
--
To view, visit https://gerrit.wikimedia.org/r/463249
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Id215527268c286d7f228dbef0e030a93843e9bdf
Gerrit-Change-Number: 463249
Gerrit-PatchSet: 1
Gerrit-Owner: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/462790 )
Change subject: [cleanup] cleanup scripts/checkimages.py
......................................................................
[cleanup] cleanup scripts/checkimages.py
- use str.format(...) instead of modulo for type specifier
arguments.
Change-Id: I27e1e12aceae7269d604e5e91030708932421d6d
---
M scripts/checkimages.py
1 file changed, 44 insertions(+), 44 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/checkimages.py b/scripts/checkimages.py
index e71be3a..43333ee 100755
--- a/scripts/checkimages.py
+++ b/scripts/checkimages.py
@@ -635,7 +635,7 @@
except Exception:
pywikibot.exception()
pywikibot.output(
- 'Another error... skipping the user..')
+ 'Another error... skipping the user...')
def uploadBotChangeFunction(self, reportPageText, upBotArray):
"""Detect the user that has uploaded the file through upload bot."""
@@ -679,8 +679,8 @@
nick = reportPageObject.latest_file_info.user
except pywikibot.PageRelatedError:
pywikibot.output(
- 'Seems that %s has only the description and not the file...'
- % self.image_to_report)
+ 'Seems that {} has only the description and not the file...'
+ .format(self.image_to_report))
repme = self.list_entry + "problems '''with the APIs'''"
self.report_image(self.image_to_report, self.rep_page, self.com,
repme)
@@ -716,8 +716,8 @@
history = self.talk_page.getLatestEditors(limit=10)
latest_user = history[0]['user']
pywikibot.output(
- 'The latest user that has written something is: %s'
- % latest_user)
+ 'The latest user that has written something is: '
+ + latest_user)
if latest_user in self.bots:
second_text = True
# A block to prevent the second message if the bot also
@@ -769,8 +769,8 @@
except (pywikibot.NoPage, pywikibot.IsRedirectPage):
return
if self.sendemailActive:
- text_to_send = re.sub(r'__user-nickname__', r'%s'
- % self.luser, emailText)
+ text_to_send = re.sub(r'__user-nickname__', r'{}'
+ .format(self.luser), emailText)
emailClass = pywikibot.User(self.site, self.luser)
try:
emailClass.send_email(emailSubj, text_to_send)
@@ -780,7 +780,7 @@
def regexGenerator(self, regexp, textrun):
"""Find page to yield using regex to parse text."""
- regex = re.compile(r'%s' % regexp, re.UNICODE | re.DOTALL)
+ regex = re.compile(r'{}'.format(regexp), re.UNICODE | re.DOTALL)
results = regex.findall(textrun)
for image in results:
yield pywikibot.FilePage(self.site, image)
@@ -831,8 +831,8 @@
def checkImageOnCommons(self):
"""Checking if the file is on commons."""
- pywikibot.output('Checking if [[%s]] is on commons...'
- % self.imageName)
+ pywikibot.output('Checking if [[{}]] is on commons...'
+ .format(self.imageName))
try:
hash_found = self.image.latest_file_info.sha1
except pywikibot.NoPage:
@@ -849,8 +849,8 @@
if pywikibot.Page(self.site,
template) in templatesInTheImage:
pywikibot.output(
- "%s is on commons but it's a service image."
- % self.imageName)
+ "{} is on commons but it's a service image."
+ .format(self.imageName))
return True # continue with the check-part
pywikibot.output(self.imageName + ' is on commons!')
@@ -865,8 +865,8 @@
if re.findall(r'\bstemma\b', self.imageName.lower()) and \
self.site.code == 'it':
pywikibot.output(
- '%s has "stemma" inside, means that it\'s ok.'
- % self.imageName)
+ "{} has 'stemma' inside, means that it's ok."
+ .format(self.imageName))
return True
# It's not only on commons but the image needs a check
@@ -944,8 +944,8 @@
if not (re.findall(dupRegex, DupPageText) or
re.findall(dupRegex, older_page_text)):
pywikibot.output(
- '%s is a duplicate and has to be tagged...'
- % dup_page)
+ '{} is a duplicate and has to be tagged...'
+ .format(dup_page))
images_to_tag_list.append(dup_page.title())
string += '* {0}\n'.format(
dup_page.title(as_link=True, textlink=True))
@@ -1029,8 +1029,8 @@
):
# the image itself, not report also this as duplicate
continue
- repme += '\n** [[:%s%s]]' % (self.image_namespace,
- dup_page.title(as_url=True))
+ repme += '\n** [[:{}{}]]'.format(
+ self.image_namespace, dup_page.title(as_url=True))
result = self.report_image(self.imageName, self.rep_page,
self.com, repme, addings=False)
@@ -1071,8 +1071,8 @@
reported = True
# Skip if the message is already there.
if short_text in text_get:
- pywikibot.output('%s is already in the report page.'
- % image_to_report)
+ pywikibot.output('{} is already in the report page.'
+ .format(image_to_report))
reported = False
elif len(text_get) >= self.logFulNumber:
if self.logFullError:
@@ -1246,7 +1246,7 @@
if not self.licenses_found and licenses_TEST:
raise pywikibot.Error(
"Invalid or broken templates found in the image's "
- 'page %s!' % self.image)
+ 'page {}!'.format(self.image))
self.allLicenses = []
if not self.list_licenses:
@@ -1289,8 +1289,8 @@
pywikibot.output('File already fixed. Skipping.')
else:
pywikibot.output(
- "The file's description for %s contains %s..."
- % (self.imageName, self.name_used))
+ "The file's description for {} contains {}..."
+ .format(self.imageName, self.name_used))
if self.mex_used.lower() == 'default':
self.mex_used = self.unvertext
if self.imagestatus_used:
@@ -1312,8 +1312,8 @@
'<nowiki>%s</nowiki>') %
(self.imageName, self.license_found))
printWithTimeZone(
- '%s seems to have a fake license: %s, reporting...'
- % (self.imageName, self.license_found))
+ '{} seems to have a fake license: {}, reporting...'
+ .format(self.imageName, self.license_found))
self.report_image(self.imageName,
rep_text=rep_text_license_fake,
addings=False)
@@ -1369,8 +1369,8 @@
Let the users to fix the image's problem alone in the first x seconds.
"""
printWithTimeZone(
- 'Skipping the files uploaded less than %s seconds ago..'
- % wait_time)
+ 'Skipping the files uploaded less than {} seconds ago..'
+ .format(wait_time))
for page in generator:
image = pywikibot.FilePage(page)
try:
@@ -1383,10 +1383,10 @@
yield image
else:
pywikibot.warning(
- 'Skipping %s, uploaded %d %s ago..'
- % ((image.title(), delta.days, 'days')
- if delta.days > 0
- else (image.title(), delta.seconds, 'seconds')))
+ 'Skipping {}, uploaded {} {} ago..'
+ .format(image.title(), delta.days, 'days')
+ if delta.days > 0
+ else (image.title(), delta.seconds, 'seconds'))
def isTagged(self):
"""Understand if a file is already tagged or not."""
@@ -1430,7 +1430,7 @@
mexCatched = tupla[8]
for k in find_list:
if find_tipe.lower() == 'findonly':
- searchResults = re.findall(r'%s' % k.lower(),
+ searchResults = re.findall(r'{}'.format(k.lower()),
self.imageCheckText.lower())
if searchResults:
if searchResults[0] == self.imageCheckText.lower():
@@ -1443,7 +1443,7 @@
self.mex_used = mexCatched
break
elif find_tipe.lower() == 'find':
- if re.findall(r'%s' % k.lower(),
+ if re.findall(r'{}'.format(k.lower()),
self.imageCheckText.lower()):
self.some_problem = True
self.text_used = text
@@ -1491,20 +1491,20 @@
try:
self.imageCheckText = self.image.get()
except pywikibot.NoPage:
- pywikibot.output('Skipping %s because it has been deleted.'
- % self.imageName)
+ pywikibot.output('Skipping {} because it has been deleted.'
+ .format(self.imageName))
return
except pywikibot.IsRedirectPage:
- pywikibot.output("Skipping %s because it's a redirect."
- % self.imageName)
+ pywikibot.output("Skipping {} because it's a redirect."
+ .format(self.imageName))
return
# Delete the fields where the templates cannot be loaded
regex_nowiki = re.compile(r'<nowiki>(.*?)</nowiki>', re.DOTALL)
regex_pre = re.compile(r'<pre>(.*?)</pre>', re.DOTALL)
self.imageCheckText = regex_nowiki.sub('', self.imageCheckText)
self.imageCheckText = regex_pre.sub('', self.imageCheckText)
- # Deleting the useless template from the description (before adding sth
- # in the image the original text will be reloaded, don't worry).
+ # Deleting the useless template from the description (before adding
+ # sth in the image the original text will be reloaded, don't worry).
if self.isTagged():
printWithTimeZone('{} is already tagged...'.format(self.imageName))
return
@@ -1551,8 +1551,8 @@
smwl)
return
else:
- pywikibot.output('%s has only text and not the specific license...'
- % self.imageName)
+ pywikibot.output('{} has only text and not the specific '
+ 'license...'.format(self.imageName))
if hiddenTemplateFound and HiddenTN:
notification = HiddenTN % self.imageName
elif nn:
@@ -1692,7 +1692,7 @@
elif len(arg) > 4:
catName = str(arg[5:])
catSelected = pywikibot.Category(pywikibot.Site(),
- 'Category:%s' % catName)
+ 'Category:{}'.format(catName))
generator = catSelected.articles(namespaces=[6])
repeat = False
elif arg.startswith('-ref'):
@@ -1723,8 +1723,8 @@
if limit == 1:
pywikibot.output('Retrieving the latest file for checking...')
else:
- pywikibot.output('Retrieving the latest %d files for checking...'
- % limit)
+ pywikibot.output('Retrieving the latest {} files for checking...'
+ .format(limit))
while True:
# Defing the Main Class.
Bot = checkImagesBot(site, sendemailActive=sendemailActive,
--
To view, visit https://gerrit.wikimedia.org/r/462790
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I27e1e12aceae7269d604e5e91030708932421d6d
Gerrit-Change-Number: 462790
Gerrit-PatchSet: 3
Gerrit-Owner: D3r1ck01 <alangiderick(a)gmail.com>
Gerrit-Reviewer: D3r1ck01 <alangiderick(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot (75)