'''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'
}
# 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
: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, '')
: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