Last active
June 2, 2016 07:41
-
-
Save hasherezade/10ad061a2cdba8f085c2 to your computer and use it in GitHub Desktop.
Minimalistic "colorfull print"
This file contains hidden or 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
| #!/usr/bin/python | |
| import sys # to args | |
| import colorterm | |
| # ==================================================================== | |
| # MAIN: | |
| def main(): | |
| colorterm.info("Hello World") | |
| colorterm.warn("Warning!") | |
| colorterm.err("System Error") | |
| if __name__ == "__main__": | |
| sys.exit(main()) |
This file contains hidden or 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
| BLUE = '\033[94m' | |
| GREEN = '\033[92m' | |
| YELLOW = '\033[93m' | |
| RED = '\033[91m' | |
| COLOR_END = '\033[0m' | |
| BOLD = "\033[1m" | |
| def color_signed_msg(color, sign, msg): | |
| if not color or not sign: | |
| print msg | |
| return | |
| print BOLD + color +'[' + sign + '] ' + COLOR_END + msg | |
| def color_msg(color,msg): | |
| if not color: | |
| print msg | |
| return | |
| print color + msg + COLOR_END | |
| def info(msg): | |
| color_signed_msg(BLUE, '*', msg) | |
| def good(msg): | |
| color_signed_msg(GREEN, '+', msg) | |
| def warn(msg): | |
| color_signed_msg(YELLOW, '!', msg) | |
| def err( msg): | |
| color_signed_msg(RED, '-', msg) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment