Merge branch 'sburns-no-colorize-notty'

main
Vincent Driessen 12 years ago
commit 11794ccef5

@ -5,6 +5,7 @@ Miscellaneous helper functions.
The formatter for ANSI colored console output is heavily based on Pygments The formatter for ANSI colored console output is heavily based on Pygments
terminal colorizing code, originally by Georg Brandl. terminal colorizing code, originally by Georg Brandl.
""" """
import sys
import os import os
@ -65,11 +66,16 @@ class _Colorizer(object):
self.codes["darkyellow"] = self.codes["brown"] self.codes["darkyellow"] = self.codes["brown"]
self.codes["fuscia"] = self.codes["fuchsia"] self.codes["fuscia"] = self.codes["fuchsia"]
self.codes["white"] = self.codes["bold"] self.codes["white"] = self.codes["bold"]
self.notty = not sys.stdout.isatty()
def reset_color(self): def reset_color(self):
return self.codes["reset"] return self.codes["reset"]
def colorize(self, color_key, text): def colorize(self, color_key, text):
if not sys.stdout.isatty()
return text
else:
return self.codes[color_key] + text + self.codes["reset"] return self.codes[color_key] + text + self.codes["reset"]
def ansiformat(self, attr, text): def ansiformat(self, attr, text):

Loading…
Cancel
Save