Skip to content
Snippets Groups Projects
Commit 584df156 authored by Sebastien Luttringer's avatar Sebastien Luttringer
Browse files

fix displaying color with --no-color

parent 45b1e2d2
No related branches found
No related tags found
No related merge requests found
......@@ -50,7 +50,11 @@ def out(message="", fd=sys.stdout, endl=os.linesep, flush=True):
'''
# color subsitution
color_pattern = "#(%s)#" % "|".join(COLOR)
message = re.sub(color_pattern, lambda obj: COLOR[obj.group(1)], message)
if not fd.isatty() or NOCOLOR:
f = lambda obj: ""
else:
f = lambda obj: COLOR[obj.group(1)]
message = re.sub(color_pattern, f, message)
# convert unicode into str before write
# this can cause issue on python 2.6
if type(message) == unicode:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment