1 # This Source Code Form is subject to the terms of the Mozilla Public
2 # License, v. 2.0. If a copy of the MPL was not distributed with this
3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
11 class NullTerminal(object):
12 """Replacement for `blessed.Terminal()` that does no formatting."""
18 def __init__(self
, stream
=None, **kwargs
):
19 self
.stream
= stream
or sys
.__stdout
__
21 self
.is_a_tty
= os
.isatty(self
.stream
.fileno())
25 class NullCallableString(six
.text_type
):
26 """A dummy callable Unicode stolen from blessings"""
29 new
= six
.text_type
.__new
__(cls
, "")
32 def __call__(self
, *args
):
33 if len(args
) != 1 or isinstance(args
[0], int):
37 def __getattr__(self
, attr
):
38 return self
.NullCallableString()
41 def Terminal(raises
=False, disable_styling
=False, **kwargs
):
43 return NullTerminal(**kwargs
)
49 return NullTerminal(**kwargs
)
50 return blessed
.Terminal(**kwargs
)