mirror of
https://github.com/pmret/papermario.git
synced 2024-11-18 17:02:46 +01:00
179998098c
* some btl_state work * msg_draw_speech_bubble * cleaners * btl_state_stuff * btl_state_update_next_enemy wip * btl_state stuff * disable_x fx + cleanup * wip * fxstuff * path funcs & cleanup * clean * model_api funcs * two action commands * action_cmd progress * UnkFunc001 * air raid func * cleanup, data migration, goodies * remove data file * git subrepo pull --force tools/splat subrepo: subdir: "tools/splat" merged: "a847090eac" upstream: origin: "https://github.com/ethteck/splat.git" branch: "master" commit: "a847090eac" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo" commit: "2f68596" * fix build * more cleanup * clean * PR comments
52 lines
1.0 KiB
Python
52 lines
1.0 KiB
Python
import sys
|
|
from colorama import init, Fore, Style
|
|
from typing import Optional
|
|
|
|
init(autoreset=True)
|
|
|
|
newline = True
|
|
|
|
Status = Optional[str]
|
|
|
|
|
|
def write(*args, status=None, **kwargs):
|
|
global newline
|
|
|
|
if not newline:
|
|
print("")
|
|
newline = True
|
|
|
|
print(status_to_ansi(status) + str(args[0]), *args[1:], **kwargs)
|
|
|
|
|
|
def error(*args, **kwargs):
|
|
write(*args, **kwargs, status="error")
|
|
sys.exit(2)
|
|
|
|
|
|
# The line_num is expected to be zero-indexed
|
|
def parsing_error_preamble(path, line_num, line):
|
|
write("")
|
|
write(f"error reading {path}, line {line_num + 1}:", status="error")
|
|
write(f"\t{line}")
|
|
|
|
|
|
def dot(status: Status = None):
|
|
global newline
|
|
|
|
print(status_to_ansi(status) + ".", end="")
|
|
newline = False
|
|
|
|
|
|
def status_to_ansi(status: Status):
|
|
if status == "ok":
|
|
return Fore.GREEN
|
|
elif status == "warn":
|
|
return Fore.YELLOW + Style.BRIGHT
|
|
elif status == "error":
|
|
return Fore.RED + Style.BRIGHT
|
|
elif status == "skip":
|
|
return Style.DIM
|
|
else:
|
|
return ""
|