Source code for pomdp_py.utils.typ

"""
Utilties for typography, i.e. dealing with
strings for the purpose of displaying them.
"""


# Colors on terminal https://stackoverflow.com/a/287944/2893053
[docs] class bcolors: WHITE = "\033[97m" CYAN = "\033[96m" MAGENTA = "\033[95m" BLUE = "\033[94m" GREEN = "\033[92m" YELLOW = "\033[93m" RED = "\033[91m" BOLD = "\033[1m" ENDC = "\033[0m"
[docs] @staticmethod def disable(): bcolors.WHITE = "" bcolors.CYAN = "" bcolors.MAGENTA = "" bcolors.BLUE = "" bcolors.GREEN = "" bcolors.YELLOW = "" bcolors.RED = "" bcolors.ENDC = ""
[docs] @staticmethod def s(color, content): """Returns a string with color when shown on terminal. `color` is a constant in `bcolors` class.""" return color + content + bcolors.ENDC
[docs] def info(content): return bcolors.s(bcolors.BLUE, content)
[docs] def note(content): return bcolors.s(bcolors.YELLOW, content)
[docs] def error(content): return bcolors.s(bcolors.GREEN, content)
[docs] def warning(content): return bcolors.s(bcolors.YELLOW, content)
[docs] def success(content): return bcolors.s(bcolors.GREEN, content)
[docs] def bold(content): return bcolors.s(bcolors.BOLD, content)
def white(content): return bcolors.s(bcolors.WHITE, content) def green(content): return bcolors.s(bcolors.GREEN, content)
[docs] def cyan(content): return bcolors.s(bcolors.CYAN, content)
[docs] def magenta(content): return bcolors.s(bcolors.MAGENTA, content)
[docs] def blue(content): return bcolors.s(bcolors.BLUE, content)
[docs] def green(content): return bcolors.s(bcolors.GREEN, content)
[docs] def yellow(content): return bcolors.s(bcolors.YELLOW, content)
[docs] def red(content): return bcolors.s(bcolors.RED, content)
[docs] def white(content): return bcolors.s(bcolors.WHITE, content)
colors = { "white", "green", "cyan", "magenta", "blue", "green", "yellow", "red", "white", }