operations
ensure_path(dir=None)
Ensure a directory path exists.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dir |
str | Path
|
The directory path to ensure existence of |
None
|
Returns
(bool): `True` if Path exists/was created
(bool): `False` if an error was encountered
Source code in src/red_utils/ext/msgpack_utils/operations.py
msgpack_deserialize(packed_str=None)
Load serialized msgpack string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
packed_str |
bytes
|
A |
None
|
Returns
(bool): `False` if deserialization fails
(str): String value from serialized `packed_str`
(dict): A dict with 2 keys, `'success'` and `'detail'`.
`success` is a `bool` indicator of deserialize operation success status.
`detail` contains the `'message'` key with the `bytestring`, as well as other
optional details to be returned.
Source code in src/red_utils/ext/msgpack_utils/operations.py
msgpack_deserialize_file(filename=None)
Load serialized msgpack string from a file and return.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename |
str
|
The path to a file with serialized data to load |
None
|
Returns
(dict): A dict with 2 keys, `'success'` and `'detail'`.
`success` is a `bool` indicator of deserialize operation success status.
`detail` contains the `'message'` key with the `bytestring`, as well as other
optional details to be returned.
Source code in src/red_utils/ext/msgpack_utils/operations.py
msgpack_serialize(_json=None)
Serialize a Python dict to a msgpack string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
_json |
dict
|
A Python |
None
|
Returns
(dict): A dict with 2 keys, `'success'` and `'detail'`.
`success` is a `bool` indicator of serialize operation success status.
`detail` contains the `'message'` key with the `bytestring`, as well as other
optional details to be returned.
Source code in src/red_utils/ext/msgpack_utils/operations.py
msgpack_serialize_file(_json=None, output_dir=SERIALIZE_DIR, filename=None)
Serialize a Python dict to a msgpack file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
_json |
dict
|
A Python |
None
|
output_dir |
str
|
Output path where file should be saved |
SERIALIZE_DIR
|
filename |
str
|
Name of the serialized file |
None
|
Returns
(dict): A dict with 2 keys, `'success'` and `'detail'`.
`success` is a `bool` indicator of serialize operation success status.
`detail` contains the `'message'` key with the `bytestring`, as well as other
optional details to be returned.