jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/513580 )
Change subject: [cleanup] Call input_choice from deprecated inputChoice function ......................................................................
[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(-)
Approvals: JJMC89: Looks good to me, approved jenkins-bot: Verified
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.