Allow notification interface to not wrap text (#3728)

This commit is contained in:
Erica Portnoy
2016-11-07 16:14:09 -08:00
committed by schoen
parent df10a6431b
commit 2b229d4b9d
2 changed files with 10 additions and 5 deletions
+8 -4
View File
@@ -55,17 +55,19 @@ class FileDisplay(object):
super(FileDisplay, self).__init__() super(FileDisplay, self).__init__()
self.outfile = outfile self.outfile = outfile
def notification(self, message, pause=True): def notification(self, message, pause=True, wrap=True):
# pylint: disable=unused-argument # pylint: disable=unused-argument
"""Displays a notification and waits for user acceptance. """Displays a notification and waits for user acceptance.
:param str message: Message to display :param str message: Message to display
:param bool pause: Whether or not the program should pause for the :param bool pause: Whether or not the program should pause for the
user's confirmation user's confirmation
:param bool wrap: Whether or not the application should wrap text
""" """
side_frame = "-" * 79 side_frame = "-" * 79
message = _wrap_lines(message) if wrap:
message = _wrap_lines(message)
self.outfile.write( self.outfile.write(
"{line}{frame}{line}{msg}{line}{frame}{line}".format( "{line}{frame}{line}{msg}{line}{frame}{line}".format(
line=os.linesep, frame=side_frame, msg=message)) line=os.linesep, frame=side_frame, msg=message))
@@ -322,16 +324,18 @@ class NoninteractiveDisplay(object):
msg += "\n\n(You can set this with the {0} flag)".format(cli_flag) msg += "\n\n(You can set this with the {0} flag)".format(cli_flag)
raise errors.MissingCommandlineFlag(msg) raise errors.MissingCommandlineFlag(msg)
def notification(self, message, pause=False): def notification(self, message, pause=False, wrap=True):
# pylint: disable=unused-argument # pylint: disable=unused-argument
"""Displays a notification without waiting for user acceptance. """Displays a notification without waiting for user acceptance.
:param str message: Message to display to stdout :param str message: Message to display to stdout
:param bool pause: The NoninteractiveDisplay waits for no keyboard :param bool pause: The NoninteractiveDisplay waits for no keyboard
:param bool wrap: Whether or not the application should wrap text
""" """
side_frame = "-" * 79 side_frame = "-" * 79
message = _wrap_lines(message) if wrap:
message = _wrap_lines(message)
self.outfile.write( self.outfile.write(
"{line}{frame}{line}{msg}{line}{frame}{line}".format( "{line}{frame}{line}{msg}{line}{frame}{line}".format(
line=os.linesep, frame=side_frame, msg=message)) line=os.linesep, frame=side_frame, msg=message))
+2 -1
View File
@@ -365,12 +365,13 @@ class IInstaller(IPlugin):
class IDisplay(zope.interface.Interface): class IDisplay(zope.interface.Interface):
"""Generic display.""" """Generic display."""
def notification(message, pause): def notification(message, pause, wrap=True):
"""Displays a string message """Displays a string message
:param str message: Message to display :param str message: Message to display
:param bool pause: Whether or not the application should pause for :param bool pause: Whether or not the application should pause for
confirmation (if available) confirmation (if available)
:param bool wrap: Whether or not the application should wrap text
""" """