hpcflow.app.CompactProblemFormatter#

class hpcflow.app.CompactProblemFormatter(width=90, console_kwargs=None, output_stream=None)#

Bases: CompactProblemFormatter

Compact exception/warning formatter. Multiple instances are allowed, but only one may be enabled at any time.

Methods

disable

Disable compact formatting of `CompactException`s and `CompactWarning`s.

enable

Enable compact formatting of `CompactException`s and `CompactWarning`s.

get_console

Rich console for printing messages.

Attributes

ERROR_COLOUR

The Rich colour used for exceptions.

WARNING_COLOUR

The Rich colour used for warnings.

ipython_shell

The IPython shell, if present.

show_tracebacks

Whether to show the traceback for `CompactException`s, in addition to the custom formatted string. Tracebacks for other exceptions are always shown.

use_rich_tracebacks

Whether to use Rich to display tracebacks.

Parameters:
  • width (int)

  • console_kwargs (dict[str, Any] | None)

  • output_stream (TextIO | None)

ERROR_COLOUR: ClassVar[str] = 'red3'#

The Rich colour used for exceptions.

WARNING_COLOUR: ClassVar[str] = 'yellow'#

The Rich colour used for warnings.

disable()#

Disable compact formatting of `CompactException`s and `CompactWarning`s.

enable()#

Enable compact formatting of `CompactException`s and `CompactWarning`s.

get_console()#

Rich console for printing messages.

For testing, the output stream will be set to something provided by a test fixture; for normal use the output stream will be sys.stderr.

Return type:

Console

property ipython_shell: Any | None#

The IPython shell, if present.

property show_tracebacks: bool#

Whether to show the traceback for `CompactException`s, in addition to the custom formatted string. Tracebacks for other exceptions are always shown.

property use_rich_tracebacks: bool#

Whether to use Rich to display tracebacks.