From 584df156504f3c7c016eaf37963dfeaa4fb05895 Mon Sep 17 00:00:00 2001
From: Sebastien Luttringer <sebastien.luttringer@smartjog.com>
Date: Thu, 15 Dec 2011 13:54:07 +0100
Subject: [PATCH] fix displaying color with --no-color

---
 installsystems/printer.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/installsystems/printer.py b/installsystems/printer.py
index 2e2e459..b107798 100644
--- a/installsystems/printer.py
+++ b/installsystems/printer.py
@@ -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:
-- 
GitLab