Build Update for wikimedia/pywikibot-core
-------------------------------------
Build: #3608
Status: Errored
Duration: 30 minutes and 36 seconds
Commit: 7341ca8 (master)
Author: Mpaa
Message: replace.py: add get_inside_exception to ReplacementListEntry
ReplacementListEntry inherits from ReplacementBase, it it does not
inherit get_inside_exception from Replacement.
Bug: T144697
Change-Id: Ibcee8691ceae2ec2c2c3678960527c14c55fb142
View the changeset: https://github.com/wikimedia/pywikibot-core/compare/81dd970b3526...7341ca86…
View the full build log and details: https://travis-ci.org/wikimedia/pywikibot-core/builds/157474513
--
You can configure recipients for build notifications in your .travis.yml file. See https://docs.travis-ci.com/user/notifications
jenkins-bot has submitted this change and it was merged.
Change subject: [IMPR] Simplify returnOlderTime()
......................................................................
[IMPR] Simplify returnOlderTime()
- rename returnOlderTime to important_image because the method does
return the most important image i.e. the most used or oldest
but not any time information
- return a FilePage object instead a title
- remove obsolete timeListGiven as data is included in listGiven
- use Page object in listGiven instead of the title
- use enumerate for counting
- use max() function to find the oldest image
- rename num_older for better readability
- add some doc for readability
- use FilePage from important_image later in the script
- use its title method instead of throw parts together
- also use title method for dup_page to collect the titles
- remove trivial doc strings
Change-Id: I9022c31d957f9afd67408de96184b4d769862472
---
M scripts/checkimages.py
1 file changed, 47 insertions(+), 52 deletions(-)
Approvals:
Mpaa: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/checkimages.py b/scripts/checkimages.py
index 02e9a0b..375fa33 100755
--- a/scripts/checkimages.py
+++ b/scripts/checkimages.py
@@ -807,35 +807,31 @@
for element in self.load(pageHiddenText):
self.hiddentemplates.add(pywikibot.Page(self.site, element))
- def returnOlderTime(self, listGiven, timeListGiven):
- """Get some time and return the oldest of them."""
- num = 0
- num_older = None
- max_usage = 0
- for element in listGiven:
- imageName = element[1]
- imagePage = pywikibot.FilePage(self.site, imageName)
- imageUsage = [page for page in imagePage.usingPages()]
- if len(imageUsage) > 0 and len(imageUsage) > max_usage:
- max_usage = len(imageUsage)
- num_older = num
- num += 1
+ def important_image(self, listGiven):
+ """
+ Get tuples of image and time, return the most used or oldest image.
- if num_older:
- return listGiven[num_older][1]
+ @param listGiven: a list of tuples which hold seconds and FilePage
+ @type listGiven: list
+ @return: the most used or oldest image
+ @rtype: FilePage
+ """
+ # find the most used image
+ inx_found = None # index of found image
+ max_usage = 0 # hold max amount of using pages
+ for num, element in enumerate(listGiven):
+ image = element[1]
+ image_used = len([page for page in image.usingPages()])
+ if image_used > max_usage:
+ max_usage = image_used
+ inx_found = num
- for element in listGiven:
- time = element[0]
- imageName = element[1]
- not_the_oldest = False
+ if inx_found is not None:
+ return listGiven[inx_found][1]
- for time_selected in timeListGiven:
- if time > time_selected:
- not_the_oldest = True
- break
-
- if not not_the_oldest:
- return imageName
+ # find the oldest image
+ sec, image = max(listGiven, key=lambda element: element[0])
+ return image
@deprecated('Page.revision_count()')
def countEdits(self, pagename, userlist):
@@ -928,7 +924,6 @@
'count': len(duplicates) - 1}))
if dupText and dupRegex:
time_image_list = []
- time_list = []
for dup_page in duplicates:
if (dup_page.title(asUrl=True) != self.image.title(asUrl=True) or
@@ -939,10 +934,8 @@
continue
data = self.timestamp.timetuple()
data_seconds = time.mktime(data)
- time_image_list.append([data_seconds, dup_page.title()])
- time_list.append(data_seconds)
- older_image = self.returnOlderTime(time_image_list, time_list)
- Page_older_image = pywikibot.FilePage(self.site, older_image)
+ time_image_list.append([data_seconds, dup_page])
+ Page_older_image = self.important_image(time_image_list)
older_page_text = Page_older_image.text
# And if the images are more than two?
string = ''
@@ -950,43 +943,42 @@
for dup_page in duplicates:
if dup_page == Page_older_image:
- # the older image, not report also this as duplicate
+ # the most used or oldest image
+ # not report also this as duplicate
continue
try:
DupPageText = dup_page.text
except pywikibot.NoPage:
- continue # The page doesn't exists
+ continue
- duplicate = dup_page.title()
if not (re.findall(dupRegex, DupPageText) or
re.findall(dupRegex, older_page_text)):
pywikibot.output(
u'%s is a duplicate and has to be tagged...'
- % duplicate)
- images_to_tag_list.append(duplicate)
- string += u"*[[:%s%s]]\n" % (self.image_namespace,
- duplicate)
+ % dup_page)
+ images_to_tag_list.append(dup_page.title())
+ string += '* {0}\n'.format(
+ dup_page.title(asLink=True, textlink=True))
else:
pywikibot.output(
u"Already put the dupe-template in the files's page"
u" or in the dupe's page. Skip.")
return # Ok - Let's continue the checking phase
- older_image_ns = u'%s%s' % (self.image_namespace, older_image)
-
# true if the image are not to be tagged as dupes
only_report = False
# put only one image or the whole list according to the request
if u'__images__' in dupText:
- text_for_the_report = re.sub(r'__images__',
- r'\n%s*[[:%s]]\n'
- % (string, older_image_ns),
- dupText)
+ text_for_the_report = dupText.replace(
+ '__images__',
+ '\n{0}* {1}\n'.format(
+ string,
+ Page_older_image.title(asLink=True, textlink=True)))
else:
- text_for_the_report = re.sub(r'__image__',
- r'%s' % older_image_ns,
- dupText)
+ text_for_the_report = dupText.replace(
+ '__image__',
+ Page_older_image.title(asLink=True, textlink=True))
# Two iteration: report the "problem" to the user only once
# (the last)
@@ -1021,10 +1013,13 @@
not dupTalkText:
only_report = True
else:
- self.report(text_for_the_report, images_to_tag_list[-1],
- dupTalkText % (older_image_ns, string),
- dupTalkHead, commTalk=dupComment_talk,
- commImage=dupComment_image, unver=True)
+ self.report(
+ text_for_the_report, images_to_tag_list[-1],
+ dupTalkText
+ % (Page_older_image.title(withNamespace=True),
+ string),
+ dupTalkHead, commTalk=dupComment_talk,
+ commImage=dupComment_image, unver=True)
if self.duplicatesReport or only_report:
if only_report:
@@ -1046,7 +1041,7 @@
if not result:
return True # If Errors, exit (but continue the check)
- if older_image != self.imageName:
+ if Page_older_image.title() != self.imageName:
# The image is a duplicate, it will be deleted. So skip the
# check-part, useless
return
--
To view, visit https://gerrit.wikimedia.org/r/281612
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I9022c31d957f9afd67408de96184b4d769862472
Gerrit-PatchSet: 5
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <Ladsgroup(a)gmail.com>
Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>
Build Update for wikimedia/pywikibot-core
-------------------------------------
Build: #3606
Status: Errored
Duration: 29 minutes and 34 seconds
Commit: 34abac3 (master)
Author: xqt
Message: [bugfix] omit mode 600 warning for non-unix platforms
- mode 600 is availlable for unix platforms only.
Therefor re-read the changes and inform the user.
Bug: T144157
Change-Id: I1bfac31cee201dbfe5b595fb7606663ec13f54f4
View the changeset: https://github.com/wikimedia/pywikibot-core/compare/cac2a99bede7...34abac3b…
View the full build log and details: https://travis-ci.org/wikimedia/pywikibot-core/builds/157323793
--
You can configure recipients for build notifications in your .travis.yml file. See https://docs.travis-ci.com/user/notifications