Reuse termcolor's environment variable to disable colors
This commit is contained in:
parent
c470138540
commit
e78714b560
2 changed files with 5 additions and 2 deletions
|
|
@ -63,7 +63,9 @@ class ConsoleApplication(BaseApplication):
|
|||
CAPS = None
|
||||
|
||||
# shell escape strings
|
||||
if sys.platform == 'win32' or not os.isatty(sys.stdout.fileno()):
|
||||
if sys.platform == 'win32' \
|
||||
or not os.isatty(sys.stdout.fileno()) \
|
||||
or os.getenv('ANSI_COLORS_DISABLED') is not None:
|
||||
#workaround to disable bold
|
||||
BOLD = ''
|
||||
NC = '' # no color
|
||||
|
|
|
|||
|
|
@ -28,7 +28,8 @@ try:
|
|||
from termcolor import colored
|
||||
except ImportError:
|
||||
def colored(s, color=None, on_color=None, attrs=None):
|
||||
if attrs is not None and 'bold' in attrs:
|
||||
if os.getenv('ANSI_COLORS_DISABLED') is None \
|
||||
and attrs is not None and 'bold' in attrs:
|
||||
return '%s%s%s' % (IFormatter.BOLD, s, IFormatter.NC)
|
||||
else:
|
||||
return s
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue