def supported(self):
"""
A class method that returns True if the current platform supports
coloring terminal output using this method. Returns False otherwise.
"""
# assuming stderr
# isatty() returns False when SSHd into Win32 machine
if 'CYGWIN' in os.environ:
return True
if not sys.stderr.isatty():
return False # auto color only on TTYs
try:
import curses
curses.setupterm()
return curses.tigetnum("colors") > 2
except:
# guess false in case of error
return False
评论列表
文章目录