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.
 
 
 
 

33 lines
714 B

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