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.
 
 
 
 

20 lines
425 B

  1. #!/usr/bin/env python3
  2. from termcolor import colored as do_color
  3. global _COLORS_ACTIVATED
  4. def set_colors_activated(activated: bool):
  5. global _COLORS_ACTIVATED
  6. _COLORS_ACTIVATED = activated
  7. def colored(text, color=None, on_color=None, attrs=None):
  8. """Decorator to use colors only when they are activated"""
  9. if not _COLORS_ACTIVATED:
  10. return text
  11. return do_color(text, color, on_color, attrs)