mythx_models.util package

Module contents

This module contains various utility functions for MythX domain models.

mythx_models.util.deserialize_api_timestamp(timestamp_str: str) → datetime.datetime[source]

Deserialize a JavaScript API timestamp into Python datetime format.

Parameters:timestamp_str – The JS timestamp, e.g. 2019-01-10T01:29:38.410Z
Returns:A Python datetime object
mythx_models.util.dict_delete_none_fields(d: Dict[KT, VT]) → Dict[KT, VT][source]

Remove all keys that have “None” values in a dict.

Parameters:d – The dictionary to sanitize
Returns:The dict instance with all “None keys” removed
mythx_models.util.serialize_api_timestamp(ts_obj: datetime.datetime) → Optional[str][source]

Serialize a Python datetime object to its JS equivalent.

Parameters:ts_obj – A Python datetime object
Returns:The JS timestamp, e.g. 2019-01-10T01:29:38.410Z