jenkins-bot merged this change.

View Change

Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
[bugfix] Add plural support to archivebot-older-than

Depends-On: I4eeeb489823318868ec70d4f114195f9b0a6925e
Bug: T218389
Change-Id: I5010c10f1ef557a11a41016fa68adf144ffbe38f
---
M scripts/archivebot.py
1 file changed, 20 insertions(+), 10 deletions(-)

diff --git a/scripts/archivebot.py b/scripts/archivebot.py
index ca998b2..59eeda8 100755
--- a/scripts/archivebot.py
+++ b/scripts/archivebot.py
@@ -380,23 +380,22 @@
"""
Check whether thread has to be archived.

- @return: archiving reason i18n string or empty string.
- @rtype: str
+ @return: the archivation reason as a dict of localization args
+ @rtype: dict
"""
+ # Archived by timestamp
algo = archiver.get_attr('algo')
re_t = re.search(r'^old\((.*)\)$', algo)
if re_t:
if not self.timestamp:
- return ''
- # TODO: handle this:
- # return 'unsigned'
+ return None
+ # TODO: handle unsigned
maxage = str2time(re_t.group(1), self.timestamp)
if self.now - self.timestamp > maxage:
duration = str2localized_duration(archiver.site, re_t.group(1))
- return i18n.twtranslate(self.code,
- 'archivebot-older-than',
- {'duration': duration})
- return ''
+ return {'duration': duration}
+ # TODO: handle marked with template
+ return None


class DiscussionPage(pywikibot.Page):
@@ -692,7 +691,18 @@
self.comment_params['archives'] \
= comma.join(a.title(as_link=True)
for a in self.archives.values())
- self.comment_params['why'] = comma.join(whys)
+ # Find out the reasons and return them localized
+ translated_whys = set()
+ for why, arg in whys.items():
+ # Archived by timestamp
+ if why == 'duration':
+ translated_whys.add(
+ i18n.twtranslate(self.site.code,
+ 'archivebot-older-than',
+ {'duration': arg,
+ 'count': self.archived_threads}))
+ # TODO: handle unsigned or archived by template
+ self.comment_params['why'] = comma.join(translated_whys)
comment = i18n.twtranslate(self.site.code,
'archivebot-page-summary',
self.comment_params)

To view, visit change 496758. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I5010c10f1ef557a11a41016fa68adf144ffbe38f
Gerrit-Change-Number: 496758
Gerrit-PatchSet: 16
Gerrit-Owner: Dvorapa <dvorapa@seznam.cz>
Gerrit-Reviewer: D3r1ck01 <xsavitar.wiki@aol.com>
Gerrit-Reviewer: Dalba <dalba.wiki@gmail.com>
Gerrit-Reviewer: Dvorapa <dvorapa@seznam.cz>
Gerrit-Reviewer: Framawiki <framawiki@tools.wmflabs.org>
Gerrit-Reviewer: JJMC89 <JJMC89.Wikimedia@gmail.com>
Gerrit-Reviewer: Mpaa <mpaa.wiki@gmail.com>
Gerrit-Reviewer: Whym <whym@whym.org>
Gerrit-Reviewer: Xqt <info@gno.de>
Gerrit-Reviewer: Zhuyifei1999 <zhuyifei1999@gmail.com>
Gerrit-Reviewer: jenkins-bot (75)
Gerrit-CC: Matěj Suchánek <matejsuchanek97@gmail.com>