diff options
author | Tim Harder <radhermit@gmail.com> | 2021-01-31 13:38:48 -0700 |
---|---|---|
committer | Tim Harder <radhermit@gmail.com> | 2021-01-31 13:39:46 -0700 |
commit | 593dddf0b5dfd4988d2bab0828b21beca5ffb96a (patch) | |
tree | 65cd603e0531a5591add6c0eb76d5e03552fe400 /src/snakeoil/formatters.py | |
parent | formatters: move stream flushing support to PlainTextFormatter (diff) | |
download | snakeoil-593dddf0b5dfd4988d2bab0828b21beca5ffb96a.tar.gz snakeoil-593dddf0b5dfd4988d2bab0828b21beca5ffb96a.tar.bz2 snakeoil-593dddf0b5dfd4988d2bab0828b21beca5ffb96a.zip |
formatters: rename TerminfoHatesOurTerminal to TerminfoUnsupported
Diffstat (limited to 'src/snakeoil/formatters.py')
-rw-r--r-- | src/snakeoil/formatters.py | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/src/snakeoil/formatters.py b/src/snakeoil/formatters.py index 8b373f4..855a1f9 100644 --- a/src/snakeoil/formatters.py +++ b/src/snakeoil/formatters.py @@ -312,21 +312,20 @@ class PlainTextFormatter(Formatter): def flush(self): self.stream.flush() -class TerminfoDisabled(Exception): - """ - Raised if Terminfo is disabled. - Only possible to see this is you're trying to generate a formatter directly - yourself - """ -class _BogusTerminfo(ValueError): - """Used internally.""" -class TerminfoHatesOurTerminal(Exception): +class TerminfoDisabled(Exception): + """Raised if Terminfo is disabled.""" + + +class _BogusTerminfo(ValueError): + """Internal terminfo exception.""" + +class TerminfoUnsupported(Exception): """Raised if our terminal type is unsupported.""" def __init__(self, term): @@ -467,7 +466,7 @@ else: curses.tigetstr('setaf'), curses.tigetstr('setab')) except (_BogusTerminfo, curses.error) as e: - raise TerminfoHatesOurTerminal(self._term) from e + raise TerminfoUnsupported(self._term) from e if not all(self._set_color): raise TerminfoDisabled( @@ -492,7 +491,7 @@ else: @steal_docs(Formatter) def write(self, *args, **kwargs): - PlainTextFormatter.write(self, *args, **kwargs) + super().write(self, *args, **kwargs) try: if self._modes: self.reset(self) @@ -548,7 +547,7 @@ def get_formatter(stream, force_color=False): try: term = 'ansi' if force_color else None return TerminfoFormatter(stream, term=term) - except (curses.error, TerminfoDisabled, TerminfoHatesOurTerminal): + except (curses.error, TerminfoDisabled, TerminfoUnsupported): # This happens if TERM is unset and possibly in more cases. # Just fall back to the PlainTextFormatter. pass |