1 from __future__
import print_function
5 _ansi = {
'red': 91,
'yellow': 93}
8 """Returns True if the given stream is a tty, else False""" 9 return hasattr(stream,
'isatty')
and stream.isatty()
12 def colorize(msg, color, file=sys.stderr, alt_text=None):
14 return '\033[%dm%s\033[0m' % (_ansi[color], msg)
16 return '%s%s' % (alt_text, msg)
22 file = kwargs.get(
'file', sys.stderr)
23 alt_text = kwargs.get(
'alt_text',
None)
24 color = kwargs.get(
'color',
None)
25 print(
colorize(msg, color, file, alt_text), *args, file=file)
29 defaults = dict(file=sys.stderr, alt_text=
'warning: ', color=
'yellow')
30 defaults.update(kwargs)
35 defaults = dict(file=sys.stderr, alt_text=
'error: ', color=
'red')
36 defaults.update(kwargs)
def message(msg, args, kwargs)
def warning(args, kwargs)
def colorize(msg, color, file=sys.stderr, alt_text=None)