jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/460767 )
Change subject: [IMPR] Rewrite suggest_help ......................................................................
[IMPR] Rewrite suggest_help
- use a list to hold all messages and combine them finally - use singular/plural variants for missing_parameters and unknown_parameters
additional_text will always be printed as last message not as second now.
Change-Id: I5934e2e1aa7f7528f1b96ee8fa3fb8c4cb276791 --- M pywikibot/bot.py 1 file changed, 15 insertions(+), 12 deletions(-)
Approvals: Framawiki: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/bot.py b/pywikibot/bot.py index ddeeeb8..aac1ed5 100644 --- a/pywikibot/bot.py +++ b/pywikibot/bot.py @@ -1066,24 +1066,27 @@ @param additional_text: Additional text added to the end. @type additional_text: str """ + messages = [] if exception: - additional_text = ('An error occured: "{0}"'.format(exception) + - additional_text) + messages.append('An error occured: "{}".'.format(exception)) if missing_generator: - additional_text = ('Unable to execute script because no generator was ' - 'defined.\n' + additional_text) + messages.append( + 'Unable to execute script because no generator was defined.') if missing_parameters: - additional_text = 'Missing parameter(s) "{0}"\n'.format( - '", "'.join(missing_parameters)) + additional_text + messages.append('Missing parameter{s} "{params}".' + .format(s='s' if len(missing_parameters) > 1 else '', + params='", "'.join(missing_parameters))) if missing_action: - additional_text = 'No action defined.\n' + additional_text + messages.append('No action defined.') if unknown_parameters: - additional_text = 'Unknown parameter(s) "{0}"\n'.format( - '", "'.join(unknown_parameters)) + additional_text + messages.append('Unknown parameter{s} "{params}".' + .format(s='s' if len(unknown_parameters) > 1 else '', + params='", "'.join(unknown_parameters))) if additional_text: - if not additional_text.endswith('\n'): - additional_text += '\n' - error(additional_text + 'Use -help for further information.') + messages.append(additional_text.strip()) + if messages: + messages.append('Use -help for further information.') + error('\n'.join(messages))
def writeToCommandLogFile():
pywikibot-commits@lists.wikimedia.org