Salome HOME
spns #34338: post build script is not embedded in archive
[tools/sat.git] / src / printcolors.py
index da76a476b4bffcce5c4aa09ff7bedf9c4f40dd37..02342c056a8e6087fda6b6e89ca66e008c73f73a 100644 (file)
@@ -18,6 +18,7 @@
 '''In this file is stored the mechanism that manage color prints in the terminal
 '''
 
+
 # define constant to use in scripts
 COLOR_ERROR = 'ERROR'
 COLOR_WARNING = 'WARNING'
@@ -39,7 +40,8 @@ __colormap__ = {
 }
 
 # list of available codes
-__code_range__ = [1, 4] + list(range(30, 38)) + list(range(40, 48)) + list(range(90, 98)) + list(range(100, 108))
+__code_range__ = ([1, 4] + list(range(30, 38)) + list(range(40, 48))
+                + list(range(90, 98)) + list(range(100, 108)))
 
 def printc(txt, code=''):
     '''print a text with colors
@@ -135,6 +137,9 @@ def cleancolor(message):
     :return: The cleaned text.
     :rtype: str
     '''
+    if message == None:
+        return message
+    
     message = message.replace('\033[0m', '')
     for i in __code_range__:
         message = message.replace('\033[%dm' % i, '')
@@ -149,10 +154,25 @@ def print_value(logger, label, value, level=1, suffix=""):
     :param level int: the level of verboseness.
     :param suffix str: the suffix to add at the end.
     '''
+    if type(value) is list:
+        skip = "\n     "
+        strValue = ""
+        i = 0
+        for v in value:
+          strValue += "%15s, " % str(v)
+          i += 1
+          if i >= 5:
+            strValue += skip
+            i = 0
+        if len(value) > 5:
+            strValue = skip + strValue
+    else:
+        strValue = str(value)
+    strValue = printcInfo(strValue)
     if logger is None:
-        print("  %s = %s %s" % (label, printcInfo(str(value)), suffix))
+        print("  %s = %s %s" % (label, strValue, suffix))
     else:
-        logger.write("  %s = %s %s\n" % (label, printcInfo(str(value)), suffix), level)
+        logger.write("  %s = %s %s\n" % (label, strValue, suffix), level)
 
 def print_color_range(start, end):
     '''print possible range values for colors