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.
 
 
 
 

28 lines
622 B

  1. #!/usr/bin/env python3
  2. from termcolor import colored as do_color
  3. try:
  4. from importlib.metadata import version
  5. except ImportError:
  6. from importlib_metadata import version
  7. KOSMORRO_VERSION = version("kosmorro")
  8. KOSMORROLIB_VERSION = version("kosmorrolib")
  9. global _COLORS_ACTIVATED
  10. def set_colors_activated(activated: bool):
  11. global _COLORS_ACTIVATED
  12. _COLORS_ACTIVATED = activated
  13. def colored(text, color=None, on_color=None, attrs=None):
  14. """Decorator to use colors only when they are activated"""
  15. if not _COLORS_ACTIVATED:
  16. return text
  17. return do_color(text, color, on_color, attrs)