jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/693947 )
Change subject: [bugfix] Show OutputOption if before_question attribute is not set ......................................................................
[bugfix] Show OutputOption if before_question attribute is not set
OutputOption has before_question attribute. The output statement inside option.result has been dropped to enable redirecting the output stream. Therefore output the option.out after result is called.
Bug: T283488 Change-Id: I7e64dddaecb1c89f8293f9748c3ad0c26e1c906f --- M pywikibot/userinterfaces/terminal_interface_base.py 1 file changed, 9 insertions(+), 4 deletions(-)
Approvals: Matěj Suchánek: Looks good to me, but someone else must approve Xqt: 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 c4abe8b..d8ff5d2 100755 --- a/pywikibot/userinterfaces/terminal_interface_base.py +++ b/pywikibot/userinterfaces/terminal_interface_base.py @@ -373,6 +373,12 @@ options. If default is not a shortcut, it'll return -1. @rtype: int (if not return_shortcut), lowercased str (otherwise) """ + def output_option(option, before_question): + """Print an OutputOption before or after question.""" + if isinstance(option, OutputOption) \ + and option.before_question is before_question: + self.stream_output(option.out + '\n') + if force and default is None: raise ValueError('With no default option it cannot be forced') if isinstance(options, Option): @@ -399,9 +405,7 @@ with self.lock: while not handled: for option in options: - if isinstance(option, OutputOption) \ - and option.before_question: - self.stream_output(option.out + '\n') + output_option(option, before_question=True) output = Option.formatted(question, options, default) if force: self.stream_output(output + '\n') @@ -413,6 +417,7 @@ for index, option in enumerate(options): if option.handled(answer): answer = option.result(answer) + output_option(option, before_question=False) handled = option.stop break
@@ -527,7 +532,7 @@ # Each warning appears twice # the second time it has a 'message' if 'message' in record.__dict__: - return None + return
record.__dict__.setdefault('newline', '\n')
pywikibot-commits@lists.wikimedia.org