29 from __future__
import print_function
33 _ansi = {
'red': 91,
'yellow': 93}
37 """Returns True if the given stream is a tty, else False""" 38 return hasattr(stream,
'isatty')
and stream.isatty()
41 def colorize(msg, color, file=sys.stderr, alt_text=None):
48 return '\033[%dm%s\033[0m' % (color, msg)
50 return '%s%s' % (alt_text, msg)
56 file = kwargs.get(
'file', sys.stderr)
57 alt_text = kwargs.get(
'alt_text',
None)
58 color = kwargs.get(
'color',
None)
59 print(
colorize(msg, color, file, alt_text), *args, file=file)
63 defaults = dict(file=sys.stderr, alt_text=
'warning: ', color=
'yellow')
64 defaults.update(kwargs)
69 defaults = dict(file=sys.stderr, alt_text=
'error: ', color=
'red')
70 defaults.update(kwargs)
def message(msg, args, kwargs)
def warning(args, kwargs)
def colorize(msg, color, file=sys.stderr, alt_text=None)