gemseo / utils

string_tools module

Pretty string utils

Classes:

MessageLine(str_format, level, args, kwargs)

Create new instance of MessageLine(str_format, level, args, kwargs)

MultiLineString()

Multi-line string lazy evaluator.

Functions:

pretty_repr(obj, **kwargs)

String representation of an object.

class gemseo.utils.string_tools.MessageLine(str_format, level, args, kwargs)

Bases: tuple

Create new instance of MessageLine(str_format, level, args, kwargs)

Attributes:

args

Alias for field number 2

kwargs

Alias for field number 3

level

Alias for field number 1

str_format

Alias for field number 0

Methods:

count(value, /)

Return number of occurrences of value.

index(value[, start, stop])

Return first index of value.

args

Alias for field number 2

count(value, /)

Return number of occurrences of value.

index(value, start=0, stop=9223372036854775807, /)

Return first index of value.

Raises ValueError if the value is not present.

kwargs

Alias for field number 3

level

Alias for field number 1

str_format

Alias for field number 0

class gemseo.utils.string_tools.MultiLineString[source]

Bases: object

Multi-line string lazy evaluator.

The creation of the string is postponed to when an instance is stringified through the __repr__ method. This is mainly used for logging complex strings or objects where the string evaluation cost may be avoided when the logging level dismisses a logging message.

Attributes:

DEFAULT_LEVEL

INDENTATION

Methods:

add(str_format, *args, **kwargs)

Add a line.

dedent()

Decrease the indentation.

indent()

Increase the indentation.

offset()

reset()

Reset the indentation.

DEFAULT_LEVEL = 0
INDENTATION = '   '
add(str_format, *args, **kwargs)[source]

Add a line.

Parameters
  • str_format (str) – string to be process by the format() method.

  • args – args passed to the format() method.

  • kwargs – kwargs passed to the format() method.

dedent()[source]

Decrease the indentation.

indent()[source]

Increase the indentation.

classmethod offset()[source]
reset()[source]

Reset the indentation.

gemseo.utils.string_tools.pretty_repr(obj, **kwargs)[source]

String representation of an object.

Parameters

obj – object.

Returns

pretty string representation.

Return type

str