clp_ffi_py.utils module#

clp_ffi_py.utils.get_formatted_timestamp(timestamp, timezone)[source]#

Gets the formatted timestamp string from the provided timestamp with the provided timezone using isoformat.

Parameters:
  • timestamp (int) – Timestamp to format.

  • timezone (tzinfo | None) – Timezone of timestamp parameter. If None is given, UTC is used by default.

Returns:

String of formatted timestamp.

Return type:

str

clp_ffi_py.utils.get_timezone_from_timezone_id(timezone_id)[source]#

Gets the Python timezone object of the provided timezone id.

Parameters:

timezone_id (str) – Timezone Id.

Returns:

Timezone object.

Raises:

RuntimeError The given timestamp ID is invalid.

Return type:

tzinfo

clp_ffi_py.utils.parse_json_str(json_str)[source]#

Wrapper of json.loads, which parses a JSON string into a Python object.

Parameters:

json_str (str) – The JSON string to parse.

Returns:

The parsed JSON object.

Return type:

Any

clp_ffi_py.utils.serialize_dict_to_msgpack(dictionary)[source]#

Serializes the given dictionary into msgpack.

Parameters:

dictionary (Dict[Any, Any]) – The dictionary to serialize.

Returns:

msgpack byte sequence.

Raises:

TypeError The given input is not a dictionary.

Return type:

bytes