Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, stream=sys.stderr, formatter=formatter.TEXT_FORMATTER,
level=None):
super(Stream, self).__init__(handlers.TTYDetectorStreamHandler(stream),
formatter, level)
def format(self, record):
if hasattr(self.stream, "isatty"):
try:
record._stream_is_a_tty = self.stream.isatty()
except ValueError:
# Stream has been closed, usually during interpretor shutdown
record._stream_is_a_tty = False
else:
record._stream_is_a_tty = False
s = super(TTYDetectorStreamHandler, self).format(record)
del record._stream_is_a_tty
return s