def color(string, color='', graphic=''):
"""
Change text color for the Linux terminal.
Args:
string (str): String to colorify
color (str): Color to colorify the string in the following list:
black, red, green, yellow, blue, purple, cyan, gr[ae]y
graphic (str): Graphic to append to the beginning of the line
"""
if not color:
if string.startswith("[!] "):
color = 'red'
elif string.startswith("[+] "):
color = 'green'
elif string.startswith("[*] "):
color = 'blue'
else:
color = 'normal'
if color not in colors:
print(colors['red'] + 'Color not found: {}'.format(color) + colors['normal'])
return
if color:
return colors[color] + graphic + string + colors['normal']
else:
return string + colors['normal']
评论列表
文章目录