Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, code, modifier=None):
self.code = '\033[%d' % code
if modifier is not None:
self.code += ';%dm' % modifier
else:
self.code += 'm'
def __repr__(self):
return repr(self.code)
reset = _Color(0)
bold = _Color(1)
faint = _Color(2)
standout = _Color(3)
underline = _Color(4)
blink = _Color(5)
overline = _Color(6)
black = _Color(30)
darkred = _Color(31)
darkgreen = _Color(32)
brown = _Color(33)
darkblue = _Color(34)
purple = _Color(35)
teal = _Color(36)
lightgray = _Color(37)
darkgray = _Color(30, 1)
red = _Color(31, 1)
green = _Color(32, 1)
yellow = _Color(33, 1)
blue = _Color(34, 1)
class _Color:
def __init__(self, code, modifier=None):
self.code = '\033[%d' % code
if modifier is not None:
self.code += ';%dm' % modifier
else:
self.code += 'm'
def __repr__(self):
return repr(self.code)
reset = _Color(0)
bold = _Color(1)
faint = _Color(2)
standout = _Color(3)
underline = _Color(4)
blink = _Color(5)
overline = _Color(6)
black = _Color(30)
darkred = _Color(31)
darkgreen = _Color(32)
brown = _Color(33)
darkblue = _Color(34)
purple = _Color(35)
teal = _Color(36)
lightgray = _Color(37)
darkgray = _Color(30, 1)
red = _Color(31, 1)
green = _Color(32, 1)
return repr(self.code)
reset = _Color(0)
bold = _Color(1)
faint = _Color(2)
standout = _Color(3)
underline = _Color(4)
blink = _Color(5)
overline = _Color(6)
black = _Color(30)
darkred = _Color(31)
darkgreen = _Color(32)
brown = _Color(33)
darkblue = _Color(34)
purple = _Color(35)
teal = _Color(36)
lightgray = _Color(37)
darkgray = _Color(30, 1)
red = _Color(31, 1)
green = _Color(32, 1)
yellow = _Color(33, 1)
blue = _Color(34, 1)
fuchsia = _Color(35, 1)
turquoise = _Color(36, 1)
white = _Color(37, 1)
darkteal = turquoise
darkyellow = brown
fuscia = fuchsia
self.code += ';%dm' % modifier
else:
self.code += 'm'
def __repr__(self):
return repr(self.code)
reset = _Color(0)
bold = _Color(1)
faint = _Color(2)
standout = _Color(3)
underline = _Color(4)
blink = _Color(5)
overline = _Color(6)
black = _Color(30)
darkred = _Color(31)
darkgreen = _Color(32)
brown = _Color(33)
darkblue = _Color(34)
purple = _Color(35)
teal = _Color(36)
lightgray = _Color(37)
darkgray = _Color(30, 1)
red = _Color(31, 1)
green = _Color(32, 1)
yellow = _Color(33, 1)
blue = _Color(34, 1)
fuchsia = _Color(35, 1)
turquoise = _Color(36, 1)
white = _Color(37, 1)
self.code += 'm'
def __repr__(self):
return repr(self.code)
reset = _Color(0)
bold = _Color(1)
faint = _Color(2)
standout = _Color(3)
underline = _Color(4)
blink = _Color(5)
overline = _Color(6)
black = _Color(30)
darkred = _Color(31)
darkgreen = _Color(32)
brown = _Color(33)
darkblue = _Color(34)
purple = _Color(35)
teal = _Color(36)
lightgray = _Color(37)
darkgray = _Color(30, 1)
red = _Color(31, 1)
green = _Color(32, 1)
yellow = _Color(33, 1)
blue = _Color(34, 1)
fuchsia = _Color(35, 1)
turquoise = _Color(36, 1)
white = _Color(37, 1)
darkteal = turquoise
underline = _Color(4)
blink = _Color(5)
overline = _Color(6)
black = _Color(30)
darkred = _Color(31)
darkgreen = _Color(32)
brown = _Color(33)
darkblue = _Color(34)
purple = _Color(35)
teal = _Color(36)
lightgray = _Color(37)
darkgray = _Color(30, 1)
red = _Color(31, 1)
green = _Color(32, 1)
yellow = _Color(33, 1)
blue = _Color(34, 1)
fuchsia = _Color(35, 1)
turquoise = _Color(36, 1)
white = _Color(37, 1)
darkteal = turquoise
darkyellow = brown
fuscia = fuchsia
# Other nice-to-have characters:
class _Characters:
def __init__(self, color, as_unicode, as_ascii):
if os.name == "nt":
self.as_string = as_ascii
else:
reset = _Color(0)
bold = _Color(1)
faint = _Color(2)
standout = _Color(3)
underline = _Color(4)
blink = _Color(5)
overline = _Color(6)
black = _Color(30)
darkred = _Color(31)
darkgreen = _Color(32)
brown = _Color(33)
darkblue = _Color(34)
purple = _Color(35)
teal = _Color(36)
lightgray = _Color(37)
darkgray = _Color(30, 1)
red = _Color(31, 1)
green = _Color(32, 1)
yellow = _Color(33, 1)
blue = _Color(34, 1)
fuchsia = _Color(35, 1)
turquoise = _Color(36, 1)
white = _Color(37, 1)
darkteal = turquoise
darkyellow = brown
fuscia = fuchsia
# Other nice-to-have characters:
class _Color:
def __init__(self, code, modifier=None):
self.code = '\033[%d' % code
if modifier is not None:
self.code += ';%dm' % modifier
else:
self.code += 'm'
def __repr__(self):
return repr(self.code)
reset = _Color(0)
bold = _Color(1)
faint = _Color(2)
standout = _Color(3)
underline = _Color(4)
blink = _Color(5)
overline = _Color(6)
black = _Color(30)
darkred = _Color(31)
darkgreen = _Color(32)
brown = _Color(33)
darkblue = _Color(34)
purple = _Color(35)
teal = _Color(36)
lightgray = _Color(37)
darkgray = _Color(30, 1)
red = _Color(31, 1)
green = _Color(32, 1)
yellow = _Color(33, 1)
def _process_tokens(tokens, *, end="\n", sep=" ", color=True):
res = ""
for i, token in enumerate(tokens):
if isinstance(token, _Color):
if color:
res += token.code
else:
res += str(token)
if i != len(tokens) -1:
res += sep
res += end
if color:
res += reset.code
return res
class _Color:
def __init__(self, code, modifier=None):
self.code = '\033[%d' % code
if modifier is not None:
self.code += ';%dm' % modifier
else:
self.code += 'm'
def __repr__(self):
return repr(self.code)
reset = _Color(0)
bold = _Color(1)
faint = _Color(2)
standout = _Color(3)
underline = _Color(4)
blink = _Color(5)
overline = _Color(6)
black = _Color(30)
darkred = _Color(31)
darkgreen = _Color(32)
brown = _Color(33)
darkblue = _Color(34)
purple = _Color(35)
teal = _Color(36)
lightgray = _Color(37)
darkgray = _Color(30, 1)
red = _Color(31, 1)