jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/281604 )
Change subject: [IMPR] Simplify report() method
......................................................................
[IMPR] Simplify report() method
The method never runs into the while loop but break always the loop.
Return from the method instead exit the loop.
Change-Id: I723d581bfd043cd20de3f9137cfbf133f3c3979b
---
M scripts/checkimages.py
1 file changed, 18 insertions(+), 28 deletions(-)
Approvals:
Dalba: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/checkimages.py b/scripts/checkimages.py
index b749c24..812ac07 100755
--- a/scripts/checkimages.py
+++ b/scripts/checkimages.py
@@ -591,7 +591,7 @@
"""Function to make the reports easier."""
self.image_to_report = image_to_report
self.newtext = newtext
- self.head = head or u''
+ self.head = head or ''
self.notification = notification
self.notification2 = notification2
@@ -603,34 +603,24 @@
notification2)
self.commTalk = commTalk
self.commImage = commImage or self.comment
-
- while True:
+ image_tagged = False
+ try:
+ image_tagged = self.tag_image(unver)
+ except pywikibot.NoPage:
+ pywikibot.output('The page has been deleted! Skip!')
+ except pywikibot.EditConflict:
+ pywikibot.output('Edit conflict! Skip!')
+ if image_tagged and self.notification:
try:
- resPutMex = self.tag_image(unver)
- except pywikibot.NoPage:
- pywikibot.output(u"The page has been deleted! Skip!")
- break
+ self.put_mex_in_talk()
except pywikibot.EditConflict:
- pywikibot.output(u"Edit conflict! Skip!")
- break
- else:
- if not resPutMex:
- break
- if self.notification:
+ pywikibot.output('Edit Conflict! Retrying...')
try:
self.put_mex_in_talk()
- except pywikibot.EditConflict:
- pywikibot.output(u"Edit Conflict! Retrying...")
- try:
- self.put_mex_in_talk()
- except:
- pywikibot.output(
- u"Another error... skipping the user..")
- break
- else:
- break
- else:
- break
+ except Exception:
+ pywikibot.exception()
+ pywikibot.output(
+ 'Another error... skipping the user..')
def uploadBotChangeFunction(self, reportPageText, upBotArray):
"""Detect the user that has uploaded the file through the upload
bot."""
@@ -653,7 +643,7 @@
reportPageText = reportPageObject.get()
except pywikibot.NoPage:
pywikibot.output(u'%s has been deleted...' % self.imageName)
- return
+ return False
# You can use this function also to find only the user that
# has upload the image (FixME: Rewrite a bit this part)
if put:
@@ -665,7 +655,7 @@
summary=self.commImage)
except pywikibot.LockedPage:
pywikibot.output(u'File is locked. Skipping.')
- return
+ return False
# paginetta it's the image page object.
try:
if reportPageObject == self.image and self.uploader:
@@ -679,7 +669,7 @@
repme = self.list_entry + "problems '''with the
APIs'''"
self.report_image(self.image_to_report, self.rep_page,
self.com,
repme)
- return
+ return False
upBots = i18n.translate(self.site, uploadBots)
user = pywikibot.User(self.site, nick)
luser = user.title(asUrl=True)
--
To view, visit
https://gerrit.wikimedia.org/r/281604
To unsubscribe, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I723d581bfd043cd20de3f9137cfbf133f3c3979b
Gerrit-PatchSet: 5
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Magul <tomasz.magulski(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>