MCPcopy Index your code
hub / github.com/python-cmd2/cmd2 / _run_cmdfinalization_hooks

Method _run_cmdfinalization_hooks

cmd2/cmd2.py:2999–3016  ·  view source on GitHub ↗

Run the command finalization hooks.

(self, stop: bool, statement: Statement | None)

Source from the content-addressed store, hash-verified

2997 return stop
2998
2999 def _run_cmdfinalization_hooks(self, stop: bool, statement: Statement | None) -> bool:
3000 """Run the command finalization hooks."""
3001 if self._initial_termios_settings is not None and self.stdin.isatty(): # type: ignore[unreachable]
3002 import io # type: ignore[unreachable]
3003 import termios
3004
3005 # Before the next command runs, fix any terminal problems like those
3006 # caused by certain binary characters having been printed to it.
3007 with self.sigint_protection, contextlib.suppress(io.UnsupportedOperation, termios.error):
3008 # This can fail if stdin is a pseudo-TTY, in which case we just ignore it
3009 termios.tcsetattr(self.stdin.fileno(), termios.TCSANOW, self._initial_termios_settings)
3010
3011 data = plugin.CommandFinalizationData(stop, statement)
3012 for func in self._cmdfinalization_hooks:
3013 data = func(data)
3014 # retrieve the final value of stop, ignoring any
3015 # modifications to the statement
3016 return data.stop
3017
3018 def runcmds_plus_hooks(
3019 self,

Callers 1

onecmd_plus_hooksMethod · 0.95

Calls 1

isattyMethod · 0.80

Tested by

no test coverage detected