Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def print(*messages, color: str = "white", dark: bool = False, prefix: str = "", parse: bool = True, **kwargs):
if "file" not in kwargs:
kwargs["file"] = stdout
#try:
columns = os.get_terminal_size().columns
#except ValueError:
# columns = None
string = ""
for message in messages:
if isinstance(message, (tuple, list, set)):
if isinstance(message[-1], bool):
*message, dark = message
if message[-1] in termcolor.COLORS.keys():
*message, color = message
message = " ".join(map(str, message))
string += termcolor.colored(message, color, attrs=["dark"] if dark else [])
#if columns:
_print((fit(string, prefix) if parse else string), **kwargs)
#else:
def __init__(self, name=None):
self.name = name
colors = list(termcolor.COLORS.keys()) # prevent RuntimeError: dictionary changed size during iteration
# add reverse and bright color
for color in colors:
termcolor.COLORS['reverse_'+color] = termcolor.COLORS[color]+10
termcolor.COLORS['bright_'+color] = termcolor.COLORS[color]+60
# for color in termcolor.COLORS.keys():