biometrics_tracker.plugin.plugin module
- class biometrics_tracker.plugin.plugin.Plugin(name: str, description: str, author_name: str, author_email: str, menus: list[biometrics_tracker.plugin.plugin.PluginMenu])
Bases:
object
Holds general info and menu specs for a plugin
Add a PluginMeu instance to the menus list property
- Parameters
menu (biometrics_tracking.config.plugin_config.PluginMenu) – the menu object to be added
- Returns
None
Retrieve a menu that matches the provided title
- Parameters
match_title (str) – the title to be match
- Returns
the retrieved PluginMenu object or None
- Rttype
Optional[biometrics_tracker.plugin.plugin.PluginMenu
Remove a menu from the menu list
- Parameters
match_title (str`) – the title of the menu to be removed
- Returns
None
- exception biometrics_tracker.plugin.plugin.PluginImportError(*args, name: Optional[str] = None, path: Optional[str] = None)
Bases:
ImportError
This exception is thrown if the PluginMenuItem.import_entry_point module importation fails due to a problem with the module code, such as a syntax error or undefined symbol
- class biometrics_tracker.plugin.plugin.PluginMenu(title: str, module_name: str, items: list[biometrics_tracker.plugin.plugin.PluginMenuItem])
Bases:
object
A dataclass that hold the information necessary to specify an application menu. This class is GUI framework agnostic. An example of an tkinter based implementation which used composition to access the functionality of this class can be found in the biometrics_tracker.gui.widgets module.
- add_item(item: PluginMenuItem)
Add a PluginMenuItem instance to the list maintained by this instance
- Parameters
item (biometrics_tracker.config.PluginMenuItem) – the PluginMenuItem instance to be added
- Returns
None
Create a menu from a PluginMenu instance, and it’s PluginMenuItem children, using callbacks provided the GUI implementation to create the menus and menu items.
- Parameters
not_found_action (Callable) – the callback to be used when an entry point can not be found
selection_action (Callable) – the callback to be used for Person, date range and DataPointType selections
add_menu_item (Callable) – the callback to be used to add menu items to the menu
add_menu (Callable) – the callback to be used to associate the menu created with a parent menu
- Returns
None
Retrieve a PluginMenuItem object that matches the provided title :param match_title: the title of the PluginMenuItem to be retrieved :type match_title: str :return: Optional[biometrics_tracker.plugin.plugin.PluginMenuItem
- class biometrics_tracker.plugin.plugin.PluginMenuItem(title: str, entry_point_name: str, select_person: bool, select_date_range: bool, select_dp_type: bool)
Bases:
object
A data class that holds the information necessary to create a menu item for a plugin entry point. The module name to be imported is supplied by the parent PluginMenu instance.
- Parameters
title (str) – the title for the menu item
entry_point_name (str) – the name of the callback for the menu item
select_person (bool) – should the menu item present a Person selection list prior to invoking the entry point
select_date_range (bool) – should the menu item present a date range selection list prior to invoking the entry point
select_dp_type (bool) – should the menu item present a DataPointType selection list prior to invoking the entry point
- import_entry_point(module_name: str, not_found_action: Callable) tuple[bool, Callable]
Imports the module specified in a PluginMenu instance, then checks for the existence of the entry point specified in the PluginMenuItem instance. If the module can not be loaded, a custom exception is raised If the module can be imported, a check is made to see if the entry point exists. If it does not exist, then then the provided not_found_actions callback is used.
- Parameters
module_name (str) – the name of the plugin module to be imported
not_found_action (Callable) – a Callable to be used as the menu item callback if the entry_point doesnt exist
- Returns
a Callable to be used as a callback for the menu item
- Return type
Callable
- exception biometrics_tracker.plugin.plugin.PluginNotFoundError(*args, name: Optional[str] = None, path: Optional[str] = None)
Bases:
ModuleNotFoundError
This exception is thrown if the PluginMenuItem.import_entry_point method can not find a module specified in a PluginMenu entry