2021-11-29 17:02:55 -05:00
|
|
|
import termcolor
|
|
|
|
import re
|
|
|
|
import sys
|
|
|
|
|
2021-12-02 13:50:15 -05:00
|
|
|
prefix = sys.argv[1] if len(sys.argv) > 1 else None
|
2021-11-29 17:02:55 -05:00
|
|
|
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:
|
2021-12-02 13:50:15 -05:00
|
|
|
if prefix:
|
|
|
|
print(prefix, end=" ")
|
2021-11-29 17:02:55 -05:00
|
|
|
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="")
|
2021-12-02 13:50:15 -05:00
|
|
|
else:
|
|
|
|
print(line, end="")
|