Skip to content

Instantly share code, notes, and snippets.

@alice1017
Created June 12, 2018 05:01
Show Gist options
  • Save alice1017/4e907b533a5c13201d2915ddd7458dda to your computer and use it in GitHub Desktop.
Save alice1017/4e907b533a5c13201d2915ddd7458dda to your computer and use it in GitHub Desktop.
#!/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