|
|
|
|
@ -447,6 +447,7 @@ class Display(metaclass=Singleton):
|
|
|
|
|
log_only: bool = False,
|
|
|
|
|
newline: bool = True,
|
|
|
|
|
caplevel: int | None = None,
|
|
|
|
|
nowrap: bool = False,
|
|
|
|
|
) -> None:
|
|
|
|
|
""" Display a message to the user
|
|
|
|
|
|
|
|
|
|
@ -464,12 +465,18 @@ class Display(metaclass=Singleton):
|
|
|
|
|
|
|
|
|
|
if not log_only:
|
|
|
|
|
|
|
|
|
|
has_newline = msg.endswith(u'\n')
|
|
|
|
|
if has_newline:
|
|
|
|
|
msg2 = msg[:-1]
|
|
|
|
|
istty = stderr and sys.__stderr__.isatty() or not stderr and sys.__stdout__.isatty()
|
|
|
|
|
|
|
|
|
|
if istty and not nowrap:
|
|
|
|
|
wrapped = textwrap.wrap(msg, self.columns, drop_whitespace=False)
|
|
|
|
|
msg2 = "\n".join(wrapped) + "\n"
|
|
|
|
|
else:
|
|
|
|
|
msg2 = msg
|
|
|
|
|
|
|
|
|
|
has_newline = msg.endswith(u'\n')
|
|
|
|
|
if has_newline:
|
|
|
|
|
msg2 = msg2[:-1]
|
|
|
|
|
|
|
|
|
|
if color:
|
|
|
|
|
msg2 = stringc(msg2, color)
|
|
|
|
|
|
|
|
|
|
@ -631,6 +638,7 @@ class Display(metaclass=Singleton):
|
|
|
|
|
deprecator: _messages.PluginInfo | None = None,
|
|
|
|
|
help_text: str | None = None,
|
|
|
|
|
obj: t.Any = None,
|
|
|
|
|
wrap_text: bool = C.NOTTY_WRAP,
|
|
|
|
|
) -> None:
|
|
|
|
|
"""
|
|
|
|
|
Display a deprecation warning message, if enabled.
|
|
|
|
|
@ -804,7 +812,7 @@ class Display(metaclass=Singleton):
|
|
|
|
|
if star_len <= 3:
|
|
|
|
|
star_len = 3
|
|
|
|
|
stars = u"*" * star_len
|
|
|
|
|
self.display(u"\n%s %s" % (msg, stars), color=color)
|
|
|
|
|
self.display(u"\n%s %s" % (msg, stars), color=color, nowrap=True)
|
|
|
|
|
|
|
|
|
|
@_proxy
|
|
|
|
|
def banner_cowsay(self, msg: str, color: str | None = None) -> None:
|
|
|
|
|
@ -822,7 +830,7 @@ class Display(metaclass=Singleton):
|
|
|
|
|
runcmd.append(to_bytes(msg))
|
|
|
|
|
cmd = subprocess.Popen(runcmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
|
|
|
(out, err) = cmd.communicate()
|
|
|
|
|
self.display(u"%s\n" % to_text(out), color=color)
|
|
|
|
|
self.display(u"%s\n" % to_text(out), color=color, nowrap=True)
|
|
|
|
|
|
|
|
|
|
def error_as_warning(
|
|
|
|
|
self,
|
|
|
|
|
|