Created
June 12, 2018 05:01
-
-
Save alice1017/4e907b533a5c13201d2915ddd7458dda to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env python | |
# coding: utf-8 | |
from prettytable import PrettyTable | |
from termcolor import (COLORS, colored) | |
colorize = (lambda msg, attrs=None: [colored(msg, c, attrs=attrs) for c in COLORS]) | |
def main(): | |
fields = ["COLOR", "GENERAL", "BOLD", "BLINK", "UNDERLINE", "REVERSE"] | |
table = PrettyTable(field_name=fields) | |
table.add_column("COLOR", COLORS.keys(), align="l") | |
table.add_column("GENERAL", colorize("GENERAL")) | |
table.add_column("BOLD", colorize("BOLD", attrs=["bold"])) | |
table.add_column("BLINK", colorize("BLINK", attrs=["blink"])) | |
table.add_column("UNDERLINE", colorize("UNDERLINE", attrs=["underline"])) | |
table.add_column("REVERSE", colorize("REVERSE", attrs=["reverse"])) | |
print table | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment