| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent f042e30 commit 1bd6fce
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,11 +3,13 @@ | |||
| 3 | 3 | import os | |
| 4 | 4 | import sys | |
| 5 | 5 | ||
| 6 | + terminal_supports_colors = True | ||
| 6 | 7 | if os.name == 'nt': # pragma: no cover (windows) | |
| 7 | 8 | from pre_commit.color_windows import enable_virtual_terminal_processing | |
| 8 | 9 | try: | |
| 9 | 10 | enable_virtual_terminal_processing() | |
| 10 | 11 | except WindowsError: | |
| 12 | + terminal_supports_colors = False | ||
| 11 | 13 | pass | |
| 12 | 14 | ||
| 13 | 15 | RED = '\033[41m' | |
@@ -29,7 +31,7 @@ def format_color(text, color, use_color_setting): | |||
| 29 | 31 | color - The color start string | |
| 30 | 32 | use_color_setting - Whether or not to color | |
| 31 | 33 | """ | |
| 32 | - if not use_color_setting: | ||
| 34 | + if not use_color_setting or not terminal_supports_colors: | ||
| 33 | 35 | return text | |
| 34 | 36 | else: | |
| 35 | 37 | return '{}{}{}'.format(color, text, NORMAL) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments