Last active
May 3, 2017 07:56
-
-
Save Derfirm/1040d0ea971d85abfe397ac2567fcd6a to your computer and use it in GitHub Desktop.
Colorize console output
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class bcolors(object): | |
HEADER = '\033[95m' | |
OKBLUE = '\033[94m' | |
OKGREEN = '\033[92m' | |
WARNING = '\033[93m' | |
FAIL = '\033[91m' | |
ENDC = '\033[0m' | |
BOLD = '\033[1m' | |
UNDERLINE = '\033[4m' | |
DEBUG = '\033[94m' | |
@classmethod | |
def warning(cls, message): | |
return cls.colorize(message, cls.WARNING) | |
@classmethod | |
def error(cls, message): | |
return cls.colorize(message, cls.FAIL) | |
@classmethod | |
def success(cls, message): | |
return cls.colorize(message, cls.OKGREEN) | |
@classmethod | |
def debug(cls, message): | |
return cls.colorize(message, cls.DEBUG) | |
@classmethod | |
def notify(cls, message): | |
return cls.colorize(message, cls.OKBLUE) | |
@classmethod | |
def colorize(cls, message, color): | |
return "{prefix}{message}{postfix}".format(prefix=color, message=message, postfix=cls.ENDC) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment