Skip to content

Commit 593dddf

Browse files
committed
formatters: rename TerminfoHatesOurTerminal to TerminfoUnsupported
1 parent 458dc15 commit 593dddf

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

src/snakeoil/formatters.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -312,21 +312,20 @@ def bg(self, color=None):
312312
def flush(self):
313313
self.stream.flush()
314314

315-
class TerminfoDisabled(Exception):
316-
"""
317-
Raised if Terminfo is disabled.
318315

319-
Only possible to see this is you're trying to generate a formatter directly
320-
yourself
321-
"""
322316

323317

324-
class _BogusTerminfo(ValueError):
325-
"""Used internally."""
326318

327319

328-
class TerminfoHatesOurTerminal(Exception):
320+
class TerminfoDisabled(Exception):
321+
"""Raised if Terminfo is disabled."""
322+
323+
324+
class _BogusTerminfo(ValueError):
325+
"""Internal terminfo exception."""
326+
329327

328+
class TerminfoUnsupported(Exception):
330329
"""Raised if our terminal type is unsupported."""
331330

332331
def __init__(self, term):
@@ -467,7 +466,7 @@ def __init__(self, stream, term=None, encoding=None):
467466
curses.tigetstr('setaf'),
468467
curses.tigetstr('setab'))
469468
except (_BogusTerminfo, curses.error) as e:
470-
raise TerminfoHatesOurTerminal(self._term) from e
469+
raise TerminfoUnsupported(self._term) from e
471470

472471
if not all(self._set_color):
473472
raise TerminfoDisabled(
@@ -492,7 +491,7 @@ def bg(self, color=None):
492491

493492
@steal_docs(Formatter)
494493
def write(self, *args, **kwargs):
495-
PlainTextFormatter.write(self, *args, **kwargs)
494+
super().write(self, *args, **kwargs)
496495
try:
497496
if self._modes:
498497
self.reset(self)
@@ -548,7 +547,7 @@ def get_formatter(stream, force_color=False):
548547
try:
549548
term = 'ansi' if force_color else None
550549
return TerminfoFormatter(stream, term=term)
551-
except (curses.error, TerminfoDisabled, TerminfoHatesOurTerminal):
550+
except (curses.error, TerminfoDisabled, TerminfoUnsupported):
552551
# This happens if TERM is unset and possibly in more cases.
553552
# Just fall back to the PlainTextFormatter.
554553
pass

tests/module/test_formatters.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,9 @@ def test_terminfo(self):
183183
self._test_stream(
184184
stream, f, ('lala',), ('lala', '\n'))
185185

186-
def test_terminfo_hates_term(self):
186+
def test_unsupported_term(self):
187187
stream = TemporaryFile()
188-
with pytest.raises(formatters.TerminfoHatesOurTerminal):
188+
with pytest.raises(formatters.TerminfoUnsupported):
189189
formatters.TerminfoFormatter(stream, term='dumb')
190190

191191
@issue7567

0 commit comments

Comments
 (0)