papermario/tools/splat/util/log.py
alex 9900e9a2b8
More image splits (#272)
* A number of new image splits

* Address comments.

* git subrepo pull --force --branch=imgflip tools/splat

subrepo:
  subdir:   "tools/splat"
  merged:   "9caaa45df9"
upstream:
  origin:   "https://github.com/ethteck/splat.git"
  branch:   "imgflip"
  commit:   "9caaa45df9"
git-subrepo:
  version:  "0.4.3"
  origin:   "???"
  commit:   "???"

* use flip_y over flip

* git subrepo pull --force --branch=imgflip tools/splat

subrepo:
  subdir:   "tools/splat"
  merged:   "ef663ec0d5"
upstream:
  origin:   "https://github.com/ethteck/splat.git"
  branch:   "imgflip"
  commit:   "ef663ec0d5"
git-subrepo:
  version:  "0.4.3"
  origin:   "???"
  commit:   "???"

* use flip_y

* git subrepo pull --force --branch=imgflip tools/splat

subrepo:
  subdir:   "tools/splat"
  merged:   "3144dc17f6"
upstream:
  origin:   "https://github.com/ethteck/splat.git"
  branch:   "imgflip"
  commit:   "3144dc17f6"
git-subrepo:
  version:  "0.4.3"
  origin:   "???"
  commit:   "???"

Co-authored-by: JoshDuMan <Joshua.Shoup.1996@gmail.com>
2021-04-22 01:01:00 +09:00

41 lines
845 B
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)
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 ""