polytex.thirdparty
Subpackages
Submodules
polytex.thirdparty.bcolors module
digraph inheritance9db8327bf7 { bgcolor=transparent; rankdir=TB; size=""; "bcolors" [URL="#polytex.thirdparty.bcolors.bcolors",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="[Simple Python class to create colored messages for command line printing]"]; }- class polytex.thirdparty.bcolors.bcolors[source]
Bases:
object[Simple Python class to create colored messages for command line printing] (https://gist.github.com/tuvokki/14deb97bef6df9bc6553)
Helper class to print colored output
To use code like this, you can do something like
- print bcolors.WARNING
“Warning: No active frommets remain. Continue?”
bcolors.ENDC
you can also use the convenience method bcolors.colored like this
>>> print(bcolors.colored("This frumble is underlined", bcolors.UNDERLINE))
- or use one of the following convenience methods:
warning, fail, ok, okblue, header
Examples
>>> print(bcolors.warning("This is dangerous"))
Method calls can be nested too, print an underlined header do this:
>>> print(bcolors.header(bcolors.colored("The line under this text is purple too ... ", bcolors.UNDERLINE)))
Methods
colored(message, color)fail(message)header(message)ok(message)okblue(message)warning(message)- BOLD = '\x1b[1m'
- ENDC = '\x1b[0m'
- FAIL = '\x1b[91m'
- HEADER = '\x1b[95m'
- OKBLUE = '\x1b[94m'
- OKCYAN = '\x1b[96m'
- OKGREEN = '\x1b[92m'
- UNDERLINE = '\x1b[4m'
- WARNING = '\x1b[93m'