22 lines
547 B
Python
22 lines
547 B
Python
import termcolor
|
|
import re
|
|
import sys
|
|
|
|
pacman_colors = dict()
|
|
pacman_attrs = dict()
|
|
|
|
def add_color_attr(field, color, *attrs):
|
|
pacman_colors[field] = color
|
|
pacman_attrs[field] = attrs
|
|
|
|
add_color_attr("==>", "green", "bold")
|
|
add_color_attr("->", "blue", "bold")
|
|
|
|
for line in sys.stdin:
|
|
if "==>" in line or "->" in line:
|
|
for part in re.split(r'(\s+)', line):
|
|
color = pacman_colors.get(part, "white")
|
|
attrs = pacman_attrs.get(part, ["bold"])
|
|
|
|
termcolor.cprint(part, color, attrs=attrs, end="")
|