Skip to content

Commit c755662

Browse files
committed
suppress colorization if stdout is not a tty
1 parent 1497c59 commit c755662

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

pythonforandroid/toolchain.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,16 @@
4141
import argparse
4242
from appdirs import user_data_dir
4343
import sh
44-
from colorama import Style, Fore
44+
if sys.stdout.isatty():
45+
from colorama import Style, Fore
46+
else:
47+
from collections import defaultdict
48+
class colorama_shim(object):
49+
def __init__(self):
50+
self._dict = defaultdict(str)
51+
def __getattr__(self, key):
52+
return self._dict[key]
53+
Style = Fore = colorama_shim()
4554

4655
user_dir = dirname(realpath(os.path.curdir))
4756
toolchain_dir = dirname(__file__)

0 commit comments

Comments
 (0)