update
Some checks are pending
Setup Native Action / native (3.12.7) (push) Waiting to run
Setup Native Action / docker (3.12.7) (push) Waiting to run

This commit is contained in:
KaySar12 2025-03-20 08:35:59 +07:00
parent 7ca423a22f
commit e0c0e834fe

View File

@ -1,29 +1,42 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
def colorize(text, code): def colorize(text, code):
"""Colorizes text using ANSI escape codes.""" """Colorizes text using ANSI escape codes."""
return f"\033[{code}m{text}\033[0m" return f"\033[{code}m{text}\033[0m"
def Show(status, message): def Show(status, message):
"""Displays a message with a status indicator.""" """Displays a message with a status indicator."""
colors = { colors = {
0: (colorize("[", "90")+colorize(" OK ", "38;5;154") + colorize("]", "90")), # Green, Grey 0: (
1: (colorize("[", "90")+colorize(" FAILED ", "91") + colorize("]", "90")), # Red, Grey colorize("[", "90") + colorize(" OK ", "38;5;154") + colorize("]", "90")
2: (colorize("[", "90")+colorize(" INFO ", "38;5;154") + colorize("]", "90")), # Green, Grey ), # Green, Grey
3: (colorize("[", "90")+colorize(" NOTICE ", "33") + colorize("]", "90")), # Yellow, Grey 1: (
} colorize("[", "90") + colorize(" FAILED ", "91") + colorize("]", "90")
print(f"{colors.get(status, '')} {message}") ), # Red, Grey
if status == 1: 2: (
exit(1) colorize("[", "90") + colorize(" INFO ", "38;5;154") + colorize("]", "90")
), # Green, Grey
3: (
colorize("[", "90") + colorize(" NOTICE ", "33") + colorize("]", "90")
), # Yellow, Grey
}
print(f"{colors.get(status, '')} {message}")
if status == 1:
exit(1)
def Warn(message): def Warn(message):
"""Displays a warning message in red.""" """Displays a warning message in red."""
print(colorize(message, "91")) print(colorize(message, "91"))
def GreyStart(): def GreyStart():
"""Starts a grey-colored output.""" """Starts a grey-colored output."""
print(colorize("", "90"), end="") print(colorize("", "90"), end="")
def ColorReset(): def ColorReset():
"""Resets the output color.""" """Resets the output color."""
print("\033[0m", end="") print("\033[0m", end="")