56 lines
1.7 KiB
Python
56 lines
1.7 KiB
Python
import sys
|
|
import re
|
|
import termcolor
|
|
|
|
prefix = termcolor.colored("[", "white", attrs=["bold"])
|
|
prefix += termcolor.colored(sys.argv[1].rjust(4), "red", attrs=["bold"])
|
|
prefix += ","
|
|
prefix += termcolor.colored(f"v{sys.argv[2]}".ljust(4), "magenta")
|
|
prefix += termcolor.colored("] ", "white", attrs=["bold"])
|
|
|
|
#proto = sys.argv[1].rjust(4)
|
|
#vers = sys.argv[2].ljust(3)
|
|
def print_prefix():
|
|
print(prefix, end="")
|
|
# termcolor.cprint("[", "white", attrs=["bold"], end="")
|
|
#termcolor.cprint(proto, "red", attrs=["bold"], end="")
|
|
#termcolor.cprint(",", "white", end="")
|
|
#termcolor.cprint(f"v{vers}", "magenta", end="")
|
|
#termcolor.cprint("] ", "white", attrs=["bold"], end="")
|
|
|
|
text = ""
|
|
def print_text(color, attr=None):
|
|
global text
|
|
termcolor.cprint(text, color=color, attrs=[attr] if attr else None, end="")
|
|
text = ""
|
|
|
|
def print_config():
|
|
global text
|
|
key, val = re.split("--", text)
|
|
if key != "MKFS_OPTIONS " and val[:3] != " -o":
|
|
print_prefix()
|
|
termcolor.cprint(key, "cyan", attrs=["bold"], end="")
|
|
termcolor.cprint("--", "white", end="")
|
|
termcolor.cprint(val, "white", attrs=["bold"], end="")
|
|
text = ""
|
|
|
|
while c := sys.stdin.read(1):
|
|
text += c
|
|
if re.match("^PLATFORM.*PREEMPT", text):
|
|
text += "\n"
|
|
print_config()
|
|
text = "COMPILED --"
|
|
elif re.match("^[A-Z_]+[ ]+-- .*?\n", text):
|
|
print_config()
|
|
elif re.match("[a-z]+/[\d]+[ ]", text):
|
|
print_prefix()
|
|
print_text("blue")
|
|
elif re.match("[ ]?[\d]+s", text):
|
|
print_text("green")
|
|
elif re.match(" ... ", text):
|
|
print_text("white")
|
|
elif re.match("\[not run\]", text):
|
|
print_text("yellow", "bold")
|
|
elif c == "\n":
|
|
print_text("white", "bold")
|