[fix] Display colorized messages correctly outside a tty

This commit is contained in:
kload 2014-05-24 19:23:56 +00:00
parent 282ae99cab
commit 1bc6308b3a

View file

@ -31,7 +31,10 @@ def colorize(astr, color):
- color -- Name of the color
"""
return '\033[{:d}m\033[1m{:s}\033[m'.format(colors_codes[color], astr)
if os.isatty(1):
return '\033[{:d}m\033[1m{:s}\033[m'.format(colors_codes[color], astr)
else:
return astr
def pretty_print_dict(d, depth=0):
"""Print a dictionary recursively