biometrics_tracker.plugin.json_handler module
- class biometrics_tracker.plugin.json_handler.PluginJSONEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)
Bases:
JSONEncoder
Implements a custom json.JSONEncoder to encode instances of Plugin, PluginMenu and PluginMenuItem instances
- default(obj: Any)
This method is invoked to handle data types that can’t be handled by the standard JSONEncoder
- Parameters
obj –
- Returns
Any
- biometrics_tracker.plugin.json_handler.plugin_object_hook(obj_dict: dict) Union[dict, Plugin, PluginMenu, PluginMenuItem]
A custom object hook function to handle the decoding of JSON representations of ConfigInfo, ImportSpecs and ExportSpecs
- Parameters
obj_dict (dict[str, str]) – a dict containing JSON names and values
- Returns
an instance of the appropriate class (e.g. ConfigInfo, ImportSpecs, etc)
- Return type
Union[dict, plugin.Plugin, plugin.PluginMenu, plugin.PluginMenuItem]
- biometrics_tracker.plugin.json_handler.retrieve_plugin(plugin_json: Path) Plugin
Deserialize the Plugin object from a JSON file
- Parameters
plugin_json (pathlib.Path) – a Path object associated with the JSON file
- Returns
the deserialized Plugin object
- Return type
- biometrics_tracker.plugin.json_handler.retrieve_plugins(plugin_path: Path) list[biometrics_tracker.plugin.plugin.Plugin]
Deserialize the Plugin objects encoded in JSON file in the plugins folder
- Parameters
plugin_path – a Path object pointing to the folder containing the Plugin JSON files
- Type
pathlib.Path
- Returns
a list of de-serialized Plugin objects
- Return type
list[plugin.PluginMenu]
- biometrics_tracker.plugin.json_handler.save_plugins(plugins: list[biometrics_tracker.plugin.plugin.Plugin], plugin_path: Path)
Serialize a list of Plugin instances to JSON files. The file names are based on the Plugin.name and author_name properties
- Parameters
plugins (list[biometrics_tracker.plugin.plugin.Plugin]) – a list of Plugin objects
plugin_path (pathlib.Path) – a Path object pointing to the plugin folder
- Returns
None