debug

class jnrbase.debug.DebugPrint(_DebugPrint__handle)[source]

Verbose print wrapper for debugging.

Configure new DebugPrint handler.

Parameters

__handle – File handle to override

static disable()[source]

Re-attach sys.stdout to its previous file handle.

Return type

None

static enable()[source]

Patch sys.stdout to use DebugPrint.

Return type

None

write(_DebugPrint__text)[source]

Write text to the debug stream.

Parameters

__text – Text to write

Return type

int

Functions

jnrbase.debug.noisy_wrap(__func)[source]

Decorator to enable DebugPrint for a given function.

Parameters

__func (Callable) – Function to wrap

Return type

Callable

Returns

Wrapped function

jnrbase.debug.on_enter(__msg=None)[source]

Decorator to display a message when entering a function.

See also: __debug_decorator()

Parameters

__msg (Union[Callable, str, None]) – Message to display

Return type

Callable

Returns

Wrapped function

jnrbase.debug.on_exit(__msg=None)[source]

Decorator to display a message when exiting a function.

See also: __debug_decorator()

Parameters

__msg (Union[Callable, str, None]) – Message to display

Return type

Callable

Returns

Wrapped function

Examples

>>> @on_enter()
... def f():
...     print('Hello')
>>> f()
Entering 'f'(<function f at 0x...>)
Hello
>>> f = on_exit(f)
>>> f()
Entering 'f'(<function f at 0x...>)
Hello
Exiting 'f'(<function f at 0x...>)
>>> on_enter(lambda: None)()
Entering '<lambda>'(<function <lambda> at 0x...>)