We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 681e499 commit 045b2e7Copy full SHA for 045b2e7
1 file changed
python/code/wypp/ansi.py
@@ -1,4 +1,6 @@
1
import re
2
+import sys
3
+import os
4
5
RESET = "\u001b[0;0m"
6
BOLD = "\u001b[1m"
@@ -21,8 +23,20 @@
21
23
YELLOW = "\u001b[1;33m"
22
24
WHITE = "\u001b[1;37m"
25
26
+def useColors():
27
+ if "NO_COLOR" in os.environ:
28
+ return False
29
+ if not sys.stdout.isatty():
30
31
+ if os.environ.get("TERM") == "dumb":
32
33
+ return True
34
+
35
def color(s, color):
- return color + s + RESET
36
+ if useColors():
37
+ return color + s + RESET
38
+ else:
39
+ return s
40
41
def green(s):
42
return color(s, GREEN + BOLD)
0 commit comments