jenkins-bot submitted this change.

View Change

Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
[IMPR] Add replacement description to -summary message

To add the replacements to -summary option a %(description)s placeholder
must be used. For example:
-summary:"Bot operated replacement:%(description)s done."
includes all replacements within the summary string like
"Bot operated replacement: (-a +b) done."

Change-Id: I21bb8ce1f53f0155f608e12a4f6b3f3f2dfafada
---
M scripts/replace.py
1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/scripts/replace.py b/scripts/replace.py
index a9187e8..7f4399c 100755
--- a/scripts/replace.py
+++ b/scripts/replace.py
@@ -57,7 +57,10 @@

-summary:XYZ Set the summary message text for the edit to XYZ, bypassing
the predefined message texts with original and replacements
- inserted. Can't be used with -automaticsummary.
+ inserted. To add the replacements to your summary use the
+ %(description)s placeholder, for example:
+ -summary:"Bot operated replacement: %(description)s"
+ Can't be used with -automaticsummary.

-automaticsummary Uses an automatic summary for all replacements which don't
have a summary defined. Can't be used with -summary.
@@ -640,19 +643,20 @@
summary_messages.add(replacement.edit_summary)
elif replacement.default_summary:
default_summaries.add((replacement.old, replacement.new))
+
summary_messages = sorted(summary_messages)
if default_summaries:
if self.opt.summary:
- summary_messages.insert(0, self.opt.summary)
+ msg = self.opt.summary
else:
- comma = self.site.mediawiki_message('comma-separator')
- default_summary = comma.join(
- '-{0} +{1}'.format(*default_summary)
- for default_summary in default_summaries)
- summary_messages.insert(0, i18n.twtranslate(
- self.site, 'replace-replacing',
- {'description': ' ({0})'.format(default_summary)}
- ))
+ msg = i18n.twtranslate(self.site, 'replace-replacing')
+ comma = self.site.mediawiki_message('comma-separator')
+ default_summary = comma.join(
+ '-{} +{}'.format(*default_summary)
+ for default_summary in default_summaries)
+ desc = {'description': ' ({})'.format(default_summary)}
+ summary_messages.insert(0, msg % desc)
+
semicolon = self.site.mediawiki_message('semicolon-separator')
return semicolon.join(summary_messages)


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

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I21bb8ce1f53f0155f608e12a4f6b3f3f2dfafada
Gerrit-Change-Number: 668344
Gerrit-PatchSet: 4
Gerrit-Owner: Xqt <info@gno.de>
Gerrit-Reviewer: Bináris <wikiposta@gmail.com>
Gerrit-Reviewer: D3r1ck01 <xsavitar.wiki@aol.com>
Gerrit-Reviewer: Dvorapa <dvorapa@seznam.cz>
Gerrit-Reviewer: Klein Muçi <kleinmuci@gmail.com>
Gerrit-Reviewer: Xqt <info@gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged