Skip to content

format

format1

format1(data: str | Dict | List, try_convert_float: bool = False, **specs)

Partial string formatting for data in case of insufficient specifications.

PARAMETER DESCRIPTION
data

The data to format.

TYPE: str | dict | list

try_convert_float

Try to convert the formatted string to float, by default False

TYPE: bool DEFAULT: False

specs

The specifications for the formatting.

DEFAULT: {}

format2

format2(
    data: str | Dict | List,
    try_convert_float: bool = False,
    *,
    model: Any = None,
    model_get_kwargs: Dict[str, Any] | None = None,
    **specs
)

Format patterns <var> to the value of the variable, in addition to format1, keys in dict are formatted using format1.

PARAMETER DESCRIPTION
data

The data to format.

TYPE: str | dict | list

try_convert_float

Try to convert the formatted string to float, by default False

TYPE: bool DEFAULT: False

model

The model object to get the variable values from if needed, try to use model.getattr first, then model.get, by default None

TYPE: Model DEFAULT: None

model_get_kwargs

The keyword arguments to pass to the model's get method.

TYPE: dict DEFAULT: None

specs

The specifications for the formatting.

DEFAULT: {}