Mirror of espurna firmware for wireless switches and more
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
933 B

  1. from __future__ import print_function
  2. import sys
  3. import click
  4. class Color(object):
  5. BLACK = "\x1b[1;30m"
  6. RED = "\x1b[1;31m"
  7. GREEN = "\x1b[1;32m"
  8. YELLOW = "\x1b[1;33m"
  9. BLUE = "\x1b[1;34m"
  10. MAGENTA = "\x1b[1;35m"
  11. CYAN = "\x1b[1;36m"
  12. WHITE = "\x1b[1;37m"
  13. LIGHT_GREY = "\x1b[0;30m"
  14. LIGHT_RED = "\x1b[0;31m"
  15. LIGHT_GREEN = "\x1b[0;32m"
  16. LIGHT_YELLOW = "\x1b[0;33m"
  17. LIGHT_BLUE = "\x1b[0;34m"
  18. LIGHT_MAGENTA = "\x1b[0;35m"
  19. LIGHT_CYAN = "\x1b[0;36m"
  20. LIGHT_WHITE = "\x1b[0;37m"
  21. def clr(color, text):
  22. return color + str(text) + "\x1b[0m"
  23. def print_warning(message, color=Color.LIGHT_YELLOW):
  24. print(clr(color, message), file=sys.stderr)
  25. def print_filler(fill, color=Color.WHITE, err=False):
  26. width, _ = click.get_terminal_size()
  27. if len(fill) > 1:
  28. fill = fill[0]
  29. out = sys.stderr if err else sys.stdout
  30. print(clr(color, fill * width), file=out)