40 lines
1.2 KiB
Python
40 lines
1.2 KiB
Python
import sys
|
|
import os
|
|
import termcolor
|
|
import re
|
|
|
|
make_colors = dict()
|
|
make_attrs = dict()
|
|
|
|
def add_color_attr(field, color, *attrs):
|
|
make_colors[field] = color
|
|
make_attrs[field] = attrs
|
|
|
|
add_color_attr("Kernel:", "blue", "bold")
|
|
add_color_attr("is", "blue", "bold")
|
|
add_color_attr("ready", "blue", "bold")
|
|
add_color_attr("CC", "cyan", "bold")
|
|
add_color_attr("[M]", "magenta", "bold")
|
|
add_color_attr("MODPOST", "magenta", "bold")
|
|
add_color_attr("MODINFO", "magenta", "bold")
|
|
add_color_attr("DESCEND", "white", "dark")
|
|
add_color_attr("objtool", "yellow", "dark", "bold")
|
|
add_color_attr("LD", "yellow")
|
|
|
|
text = ""
|
|
while c := sys.stdin.read(1):
|
|
text += c
|
|
if text[0] == "#":
|
|
if re.match("^#(.*?)\n", text):
|
|
termcolor.cprint(text, "blue", attrs=["dark", "bold"], end="")
|
|
text = ""
|
|
elif c in (" ", "\n"):
|
|
if "/" in text or "(#" in text or os.path.exists(text):
|
|
color = "magenta" if re.match("module", text, re.I) else "white"
|
|
attrs = ["bold"]
|
|
else:
|
|
color = make_colors.get(text.strip(), "green")
|
|
attrs = make_attrs.get(text.strip(), [])
|
|
termcolor.cprint(text, color, attrs=attrs, end="")
|
|
text = ""
|