Last active
November 16, 2019 06:47
-
-
Save gsscoder/ea38b07531a7253aa98072ede45329a8 to your computer and use it in GitHub Desktop.
Checks if terminal supports colors
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def supports_color(): | |
| # Ripped from: https://github.com/django/django/blob/master/django/core/management/color.py#L12 | |
| plat = sys.platform | |
| supported_platform = plat != 'Pocket PC' and (plat != 'win32' or 'ANSICON' in os.environ) | |
| # isatty is not always implemented, #6223. | |
| is_a_tty = hasattr(sys.stdout, 'isatty') and sys.stdout.isatty() | |
| return supported_platform and is_a_tty |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment