Plugin Manager

class hal_py.plugin_manager.PluginFeature

A feature provided by a plugin, such as a parser or a writer.

property args

Additional arguments of the feature, holding the supported file extensions if a parser or writer is registered.

Type

list[str]

property description

The description of the feature.

Type

str

property feature

The kind of feature that is provided.

Type

hal_py.FacExtensionInterface.Feature

hal_py.plugin_manager.add_existing_options_description(existing_options: hal_py.ProgramOptions) None

Register existing program options to avoid reuse by plugins.

Parameters

existing_options (hal_py.ProgramOptions) – The program options.

hal_py.plugin_manager.add_model_changed_callback(callback: Callable[[bool, str, str], None]) int

Add a callback to notify the GUI about loaded or unloaded plugins. The callback takes a bool that is True on load and False on unload, the plugin name, and the plugin path.

Parameters

callback (lambda(bool, str, str) -> None) – The callback function.

Returns

The ID of the registered callback.

Return type

int

hal_py.plugin_manager.get_cli_plugin_flags() Dict[str, str]

Get a mapping of flags pointing to their corresponding CLI plugin.

Returns

A dict from flag to plugin name.

Return type

dict[str,str]

hal_py.plugin_manager.get_cli_plugin_options() hal_py.ProgramOptions

Get the command line interface options of all plugins.

Returns

The program options.

Return type

hal_py.ProgramOptions

hal_py.plugin_manager.get_plugin_features(name: str) List[hal_py.plugin_manager.PluginFeature]

Get the features of a plugin identified by the stem of its file name.

Parameters

name (str) – The stem of the file name of the plugin.

Returns

A list of features such as parsers or writers.

Return type

list[hal_py.plugin_manager.PluginFeature]

hal_py.plugin_manager.get_plugin_instance(plugin_name: str, initialize: bool = True, silent: bool = False) hal::BasePluginInterface

Gets the interface for a plugin specified by name. By default calls the initialize() function of the plugin. The returned object is of the plugin’s own type as soon as the Python module of that plugin has been imported, and of type hal_py.BasePluginInterface otherwise.

Parameters
  • plugin_name (str) – The name of the plugin.

  • initialize (bool) – Set to False to not call the initialize function of the plugin. Defaults to True.

  • silent (bool) – Set to True to omit the error message if the plugin is not found. Defaults to False.

Returns

The plugin interface on success, None otherwise.

Return type

hal_py.BasePluginInterface or None

hal_py.plugin_manager.get_plugin_names() Set[str]

Get the names of all loaded plugins.

Returns

The set of plugin names.

Return type

set(str)

hal_py.plugin_manager.get_plugin_path(plugin_name: str) os.PathLike

Get the full path of a plugin. On macOS, several possible file extensions are probed.

Parameters

plugin_name (str) – The name of the plugin.

Returns

The full path to the plugin within the HAL build directory.

Return type

pathlib.Path

hal_py.plugin_manager.get_ui_plugin_flags() Dict[str, str]

Get a mapping of flags pointing to their corresponding UI plugin.

Returns

A dict from flag to plugin name.

Return type

dict[str,str]

hal_py.plugin_manager.has_valid_file_extension(file_name: os.PathLike) bool

Check whether a file has an extension that is legal for a plugin on the current operating system.

Parameters

file_name (pathlib.Path) – The path to the file.

Returns

False if the extension indicates that the file cannot be a plugin, True otherwise.

Return type

bool

hal_py.plugin_manager.load(plugin_name: str, file_path: os.PathLike) bool

Load a single plugin by specifying its name and file path.

Parameters
  • plugin_name (str) – The desired name that is unique in the framework.

  • file_path (pathlib.Path) – The path to the plugin file.

Returns

True on success, False otherwise.

Return type

bool

hal_py.plugin_manager.load_all_plugins(directory_names: List[os.PathLike] = []) bool

Load all plugins in the specified directories. If directory_names is empty, the default directories will be searched.

Parameters

directory_names (list[pathlib.Path]) – A list of directory paths.

Returns

True on success, False otherwise.

Return type

bool

hal_py.plugin_manager.remove_model_changed_callback(id: int) None

Remove a registered callback.

Parameters

id (int) – The ID of the registered callback.

hal_py.plugin_manager.unload(plugin_name: str) bool

Releases a single plugin and its associated ressources.

Parameters

plugin_name (str) – The name of the plugin to unload.

Returns

True on success, False otherwise.

Return type

bool

hal_py.plugin_manager.unload_all_plugins() bool

Releases all plugins and their associated resources.

Returns

True on success, False otherwise.

Return type

bool