Remove unused property in Output class
This commit is contained in:
parent
c86e1ad863
commit
26f63fd994
1 changed files with 9 additions and 17 deletions
|
@ -50,18 +50,7 @@ class Output(object):
|
||||||
if os.name == 'nt':
|
if os.name == 'nt':
|
||||||
stream = colorama.AnsiToWin32(stream).stream
|
stream = colorama.AnsiToWin32(stream).stream
|
||||||
self.stream = stream
|
self.stream = stream
|
||||||
|
self.base_stream = stream
|
||||||
@property
|
|
||||||
def stream(self):
|
|
||||||
"""The underlaying stream."""
|
|
||||||
return self._stream
|
|
||||||
|
|
||||||
@stream.setter
|
|
||||||
def stream(self, attr):
|
|
||||||
"""Change stream and base stream. base_stream is used for terminal
|
|
||||||
interaction when _stream is redirected to a pager."""
|
|
||||||
self._stream = attr
|
|
||||||
self._base_stream = attr
|
|
||||||
|
|
||||||
def info(self, s, level=0):
|
def info(self, s, level=0):
|
||||||
"""Write an informational message."""
|
"""Write an informational message."""
|
||||||
|
@ -98,14 +87,17 @@ class Output(object):
|
||||||
else:
|
else:
|
||||||
timestamp = u''
|
timestamp = u''
|
||||||
with lock:
|
with lock:
|
||||||
|
# FIXME: context is some kind of magic tri-state:
|
||||||
|
# - non-empty string
|
||||||
|
# - explicit None
|
||||||
|
# - anything falsy (empty string is used elsewhere)
|
||||||
if self.context:
|
if self.context:
|
||||||
self.stream.write(u'%s%s> ' % (timestamp, self.context))
|
self.stream.write(u'%s%s> ' % (timestamp, self.context))
|
||||||
elif self.context is None:
|
elif self.context is None:
|
||||||
self.stream.write(u'%s%s> ' % (timestamp, get_threadname()))
|
self.stream.write(u'%s%s> ' % (timestamp, get_threadname()))
|
||||||
if color and self.is_tty:
|
if color and self.is_tty:
|
||||||
s = u'%s%s%s' % (color, s, Style.RESET_ALL)
|
s = u'%s%s%s' % (color, s, Style.RESET_ALL)
|
||||||
self.stream.write(str(s))
|
self.stream.write(str(s) + os.linesep)
|
||||||
self.stream.write(str(os.linesep))
|
|
||||||
self.stream.flush()
|
self.stream.flush()
|
||||||
|
|
||||||
def writelines(self, lines, level=0):
|
def writelines(self, lines, level=0):
|
||||||
|
@ -130,7 +122,7 @@ class Output(object):
|
||||||
@property
|
@property
|
||||||
def is_tty(self):
|
def is_tty(self):
|
||||||
"""Is this output stream a terminal?"""
|
"""Is this output stream a terminal?"""
|
||||||
return getattr(self._base_stream, "isatty", lambda: False)()
|
return getattr(self.base_stream, "isatty", lambda: False)()
|
||||||
|
|
||||||
@contextlib.contextmanager
|
@contextlib.contextmanager
|
||||||
def temporary_context(self, context):
|
def temporary_context(self, context):
|
||||||
|
@ -148,13 +140,13 @@ class Output(object):
|
||||||
try:
|
try:
|
||||||
if self.is_tty:
|
if self.is_tty:
|
||||||
fd = io.StringIO()
|
fd = io.StringIO()
|
||||||
self._stream = fd
|
self.stream = fd
|
||||||
with self.temporary_context(u''):
|
with self.temporary_context(u''):
|
||||||
yield
|
yield
|
||||||
if self.is_tty:
|
if self.is_tty:
|
||||||
pydoc.pager(fd.getvalue())
|
pydoc.pager(fd.getvalue())
|
||||||
finally:
|
finally:
|
||||||
self._stream = self._base_stream
|
self.stream = self.base_stream
|
||||||
|
|
||||||
|
|
||||||
out = Output()
|
out = Output()
|
||||||
|
|
Loading…
Reference in a new issue