jenkins-bot merged this change.

View Change

Approvals: JJMC89: Looks good to me, approved jenkins-bot: Verified
[cleanup] Call input_choice from deprecated inputChoice function

Also move deprecated function closer to the renamed function

Change-Id: I39cc291777f7ab5d030d614f72cb2af69cbca640
---
M pywikibot/bot.py
1 file changed, 25 insertions(+), 30 deletions(-)

diff --git a/pywikibot/bot.py b/pywikibot/bot.py
index e161e27..28e17e7 100644
--- a/pywikibot/bot.py
+++ b/pywikibot/bot.py
@@ -48,7 +48,7 @@
used.
"""
#
-# (C) Pywikibot team, 2008-2019
+# (C) Pywikibot team, 2008-2020
#
# Distributed under the terms of the MIT license.
#
@@ -502,6 +502,30 @@
automatic_quit=automatic_quit, force=force)


+@deprecated('input_choice', since='20140825')
+def inputChoice(question, answers, hotkeys, default=None):
+ """Ask the user a question with several options, return the user's choice.
+
+ DEPRECATED: Use L{input_choice} instead!
+
+ The user's input will be case-insensitive, so the hotkeys should be
+ distinctive case-insensitively.
+
+ @param question: a string that will be shown to the user. Don't add a
+ space after the question mark/colon, this method will do this for you.
+ @type question: basestring
+ @param answers: a list of strings that represent the options.
+ @type answers: list of basestring
+ @param hotkeys: a list of one-letter strings, one for each answer.
+ @param default: an element of hotkeys, or None. The default choice that
+ will be returned when the user just presses Enter.
+ @return: a one-letter string in lowercase.
+ @rtype: str
+ """
+ return input_choice(question, zip(answers, hotkeys), default=default,
+ automatic_quit=False)
+
+
def input_yn(question, default=None, automatic_quit=True, force=False):
"""
Ask the user a yes/no question and return the answer as a bool.
@@ -533,35 +557,6 @@
automatic_quit=automatic_quit, force=force) == 'y'


-@deprecated('input_choice', since='20140825')
-def inputChoice(question, answers, hotkeys, default=None):
- """Ask the user a question with several options, return the user's choice.
-
- DEPRECATED: Use L{input_choice} instead!
-
- The user's input will be case-insensitive, so the hotkeys should be
- distinctive case-insensitively.
-
- @param question: a string that will be shown to the user. Don't add a
- space after the question mark/colon, this method will do this for you.
- @type question: basestring
- @param answers: a list of strings that represent the options.
- @type answers: list of basestring
- @param hotkeys: a list of one-letter strings, one for each answer.
- @param default: an element of hotkeys, or None. The default choice that
- will be returned when the user just presses Enter.
- @return: a one-letter string in lowercase.
- @rtype: str
- """
- # make sure logging system has been initialized
- if not _handlers_initialized:
- init_handlers()
-
- return ui.input_choice(question=question, options=zip(answers, hotkeys),
- default=default, return_shortcut=True,
- automatic_quit=False)
-
-
def input_list_choice(question, answers, default=None, force=False):
"""
Ask the user the question and return one of the valid answers.

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

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I39cc291777f7ab5d030d614f72cb2af69cbca640
Gerrit-Change-Number: 513580
Gerrit-PatchSet: 3
Gerrit-Owner: Xqt <info@gno.de>
Gerrit-Reviewer: JJMC89 <JJMC89.Wikimedia@gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb@gmail.com>
Gerrit-Reviewer: jenkins-bot (75)