jenkins-bot has submitted this change and it was merged.
Change subject: [IMPR] Extend doc for ui.input_choice
......................................................................
[IMPR] Extend doc for ui.input_choice
- Also allow singleton Option instance for options parameter
Bug: T129777
Change-Id: I72d97d90b7c05bb40c44516cd41bb09ced216618
---
M pywikibot/userinterfaces/terminal_interface_base.py
1 file changed, 13 insertions(+), 8 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/userinterfaces/terminal_interface_base.py
b/pywikibot/userinterfaces/terminal_interface_base.py
index 2fbe1a8..f151ee4 100755
--- a/pywikibot/userinterfaces/terminal_interface_base.py
+++ b/pywikibot/userinterfaces/terminal_interface_base.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
"""Base for terminal user interfaces."""
#
-# (C) Pywikibot team, 2003-2015
+# (C) Pywikibot team, 2003-2016
#
# Distributed under the terms of the MIT license.
#
@@ -305,12 +305,14 @@
@param question: The question, without trailing whitespace.
@type question: basestring
- @param options: All available options. Each entry contains the full
- length answer and a shortcut of only one character. The shortcut
- must not appear in the answer. Alternatively they may be a
- Option (or subclass) instance. ChoiceException instances which have
- a full option and shortcut and will be raised if selected.
- @type options: iterable containing sequences of length 2 or Option
+ @param options: Iterable of all available options. Each entry contains
+ the full length answer and a shortcut of only one character.
+ Alternatively they may be Option (or subclass) instances or
+ ChoiceException instances which have a full option and shortcut
+ and will be raised if selected.
+ @type options: iterable containing sequences of length 2 or
+ iterable containing Option instances or ChoiceException as well.
+ Singletons of Option and its subclasses are also accepted.
@param default: The default answer if no was entered. None to require
an answer.
@type default: basestring
@@ -329,7 +331,10 @@
"""
if force and default is None:
raise ValueError('With no default option it cannot be forced')
- options = list(options)
+ if isinstance(options, Option):
+ options = [options]
+ else: # make a copy
+ options = list(options)
if len(options) == 0:
raise ValueError(u'No options are given.')
if automatic_quit:
--
To view, visit
https://gerrit.wikimedia.org/r/277073
To unsubscribe, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I72d97d90b7c05bb40c44516cd41bb09ced216618
Gerrit-PatchSet: 4
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>