API: Helpers: pretty_repr, pretty_str and base class PrettyFormat.

logwrap.pretty_repr(src, indent=0, no_indent_start=False, max_indent=20, indent_step=4)[source]

Make human readable repr of object.

Parameters:
  • src (typing.Any) – object to process
  • indent (int) – start indentation, all next levels is +indent_step
  • no_indent_start (bool) – do not indent open bracket and simple parameters
  • max_indent (int) – maximal indent before classic repr() call
  • indent_step (int) – step for the next indentation level
Returns:

formatted string

Return type:

str

logwrap.pretty_str(src, indent=0, no_indent_start=False, max_indent=20, indent_step=4)[source]

Make human readable str of object.

New in version 1.1.0.

Parameters:
  • src (typing.Any) – object to process
  • indent (int) – start indentation, all next levels is +indent_step
  • no_indent_start (bool) – do not indent open bracket and simple parameters
  • max_indent (int) – maximal indent before classic repr() call
  • indent_step (int) – step for the next indentation level
Returns:

formatted string

Return type:

str

class logwrap.PrettyFormat(object)[source]

Designed for usage as __repr__ and __str__ replacement on complex objects

New in version 1.0.2.

Changed in version 3.0.1.

__init__(max_indent=20, indent_step=4)[source]
Parameters:
  • max_indent (int) – maximal indent before classic repr() call
  • indent_step (int) – step for the next indentation level

Note

Attributes is read-only

max_indent
indent_step
next_indent(indent, multiplier=1)[source]

Next indentation value. Used internally and on __pretty_{keyword}__ calls.

Parameters:
  • indent (int) – current indentation value
  • multiplier (int) – step multiplier
Return type:

int

process_element(src, indent=0, no_indent_start=False)[source]

Make human readable representation of object.

Parameters:
  • src (typing.Any) – object to process
  • indent (int) – start indentation
  • no_indent_start (bool) – do not indent open bracket and simple parameters
Returns:

formatted string

Return type:

typing.Text

__call__(src, indent=0, no_indent_start=False)[source]

Make human readable representation of object. The main entry point.

Parameters:
  • src (typing.Any) – object to process
  • indent (int) – start indentation
  • no_indent_start (bool) – do not indent open bracket and simple parameters
Returns:

formatted string

Return type:

str

class logwrap.PrettyRepr(PrettyFormat)[source]

Designed for usage as __repr__ replacement on complex objects

New in version 3.0.0.

Changed in version 3.0.1.

__init__(max_indent=20, indent_step=4)
Parameters:
  • max_indent (int) – maximal indent before classic repr() call
  • indent_step (int) – step for the next indentation level
class logwrap.PrettyStr(PrettyFormat)[source]

Designed for usage as __repr__ replacement on complex objects

New in version 3.0.0.

Changed in version 3.0.1.

__init__(max_indent=20, indent_step=4)
Parameters:
  • max_indent (int) – maximal indent before classic repr() call
  • indent_step (int) – step for the next indentation level