def __init__(self, in_file = None):
import sys
self._line_wrap = False
self._write_pos = 0
self._file = in_file or sys.stdout
#self._file = sys.stdout
if not (hasattr(self._file, 'isatty') and self._file.isatty()):
# the stdout is not a terminal, this for example happens if the
# output is piped to less, e.g. "bin/test | less". In this case,
# the terminal control sequences would be printed verbatim, so
# don't use any colors.
self.write = self.normal_write
elif sys.platform != "win32":
# We are on *nix system we can use ansi
self.write = self.ansi_write
else:
try:
import colorama
colorama.init(wrap=False)
self._file = colorama.AnsiToWin32(self._file).stream
self.write = self.ansi_write
except ImportError:
self.write = self.normal_write
评论列表
文章目录