Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def enable_colors(mode):
Color.enabled = mode
def colored(attrib, text):
if not Color.enabled:
return text
if type(attrib) != list:
attrib = [attrib]
attrib = ''.join([Color.COLORS[a] for a in attrib])
return attrib + str(text) + Color.END
def colored(attrib, text):
if not Color.enabled:
return text
if type(attrib) != list:
attrib = [attrib]
attrib = ''.join([Color.COLORS[a] for a in attrib])
return attrib + str(text) + Color.END
def _color_logs(logs):
if logs and Color.enabled:
logs = re.sub(r'^EVENTS$', Color.COLORS['blue'], logs, flags=re.MULTILINE)
logs = re.sub(r'^STDOUT$', Color.END + Color.COLORS['yellow'], logs, flags=re.MULTILINE)
logs = re.sub(r'^STDERR$', Color.END + Color.COLORS['red'], logs, flags=re.MULTILINE)
logs = logs + Color.END
return logs
def _color_logs(logs):
if logs and Color.enabled:
logs = re.sub(r'^EVENTS$', Color.COLORS['blue'], logs, flags=re.MULTILINE)
logs = re.sub(r'^STDOUT$', Color.END + Color.COLORS['yellow'], logs, flags=re.MULTILINE)
logs = re.sub(r'^STDERR$', Color.END + Color.COLORS['red'], logs, flags=re.MULTILINE)
logs = logs + Color.END
return logs