timor.utilities.jsonable
Classes
JSONable_mixin is a mixin for any class that can be serialized with a json string. |
Module Contents
- class timor.utilities.jsonable.JSONable_mixin
JSONable_mixin is a mixin for any class that can be serialized with a json string.
- __getstate__()
Return objects which will be pickled and saved.
- __setstate__(state)
Take object from parameter and use it to retrieve class state.
- static _deduce_package_dir(filepath, content)
Logic for deducing the package directory if the JSONable object is loaded from a file.
- Parameters:
filepath (pathlib.Path) – The path to the file.
content (Union[Dict, List]) – The content of the file parsed into a dictionary.
- Note:
This method can be overridden by subclasses to provide custom package directory resolution; e.g. Task.py.
- Return type:
- classmethod from_json_data(d, *args, **kwargs)
Create from a json description.
- Parameters:
d (Dict)
- classmethod from_json_file(filepath, *args, **kwargs)
Factory method to load a class instance from a json file.
- Parameters:
filepath (Union[pathlib.Path, str]) – The path to the json file.
args – Additional arguments to pass to the from_json_data factory method of the specific class.
kwargs – Additional arguments to pass to the from_json_data factory method of the specific class.
- to_json_data()
The json-compatible serialization.
- to_json_file(save_at, *args, **kwargs)
Writes the instance to a json file.
- Parameters:
save_at (Union[pathlib.Path, str]) – File location or folder to write the class to.