mh_utils.utils

General utility functions.

Functions:

as_path(val)

Returns val as a PureWindowsPath, or None if the value is empty/None/False.

camel_to_snake(name)

Convert name from CamelCase to snake_case.

element_to_bool(val)

Returns the boolean representation of val.

make_timedelta(minutes)

Construct a timedelta from a value in minutes.

strip_string(val)

Returns val as a string, without any leading or trailing whitespace.

as_path(val)[source]

Returns val as a PureWindowsPath, or None if the value is empty/None/False.

Parameters

val (Any) – The value to convert to a path

Return type

Optional[PureWindowsPath]

camel_to_snake(name)[source]

Convert name from CamelCase to snake_case.

Parameters

name (str) – The CamelCase string to convert to snake_case.

Return type

str

element_to_bool(val)[source]

Returns the boolean representation of val.

Values of -1 are counted as True for the purposes of this function.

True values are 'y', 'yes', 't', 'true', 'on', '1', 1, -1, and '-1'.

False values are 'n', 'no', 'f', 'false', 'off', '0', and 0.

Raises

ValueError if ‘val’ is anything else.

Return type

bool

make_timedelta(minutes)[source]

Construct a timedelta from a value in minutes.

Parameters

minutes (Union[float, timedelta])

Return type

timedelta

Changed in version 0.1.0: Moved from mh_utils.cef_parser.

strip_string(val)[source]

Returns val as a string, without any leading or trailing whitespace.

Parameters

val (str)

Return type

str