pluginmanager.PluginInterface

class pluginmanager.PluginInterface(**kwargs)[source]
__init__(**kwargs)[source]

Methods

__init__(**kwargs)
add_blacklisted_directories(directories[, ...]) Adds directories to be blacklisted.
add_blacklisted_filepaths(filepaths[, ...]) Add filepaths to blacklisted filepaths.
add_blacklisted_plugins(plugins) add blacklisted plugins.
add_entry_points(names)
add_file_filters(file_filters) Adds file_filters to the internal file filters.
add_module_plugin_filters(module_plugin_filters) Adds module_plugin_filters to the internal module filters.
add_plugin_directories(paths[, ...]) Adds directories to the set of plugin directories.
add_plugin_filepaths(filepaths[, ...]) Adds filepaths to internal state.
add_plugins(plugins) Adds plugins to the internal state.
add_to_loaded_modules(modules) Manually add in modules to be tracked by the module manager.
collect_entry_point_plugins([...])
collect_plugin_directories([directories])
collect_plugin_filepaths([directories])
collect_plugins([modules, ...])
get_blacklisted_directories() Returns the set of the blacklisted directories.
get_blacklisted_filepaths() Returns the blacklisted filepaths as a set object.
get_blacklisted_plugins() gets blacklisted plugins tracked in the internal state
get_entry_points()
get_file_filters([filter_function]) Gets the file filters.
get_instances([filter_function]) Gets instances out of the internal state using the default filter supplied in filter_function.
get_loaded_modules() Returns all modules loaded by this instance.
get_module_plugin_filters([filter_function]) Gets the internal module filters.
get_plugin_directories() Returns the plugin directories in a set object
get_plugin_filepaths() returns the plugin filepaths tracked internally as a set object.
get_plugins([filter_function]) Gets out the plugins from the internal state.
load_modules([filepaths])
remove_blacklisted_directories(directories) Attempts to remove the directories from the set of blacklisted directories.
remove_blacklisted_filepaths(filepaths) Removes filepaths from blacklisted filepaths.
remove_blacklisted_plugins(plugins) removes plugins from the blacklisted plugins.
remove_entry_points(names)
remove_file_filters(file_filters) Removes the file_filters from the internal state.
remove_module_plugin_filters(...) Removes module_plugin_filters from the internal module filters.
remove_plugin_directories(paths) Removes any directories from the set of plugin directories.
remove_plugin_filepaths(filepaths) Removes filepaths from internal state.
remove_plugins(plugins) removes plugins from the internal state
set_blacklisted_directories(directories[, ...]) Sets the directories to be blacklisted.
set_blacklisted_filepaths(filepaths[, ...]) Sets internal blacklisted filepaths to filepaths.
set_blacklisted_plugins(plugins) sets blacklisted plugins.
set_entry_points(names)
set_file_filters(file_filters) Sets internal file filters to file_filters by tossing old state.
set_module_plugin_filters(module_plugin_filters) Sets the internal module filters to module_plugin_filters module_plugin_filters may be a single object or an iterable.
set_plugin_directories(paths[, ...]) Sets the plugin directories to directories.
set_plugin_filepaths(filepaths[, ...]) Sets internal state to filepaths.
set_plugins(plugins) sets plugins to the internal state.
track_site_package_paths() A helper method to add all of the site packages tracked by python to the set of plugin directories.
add_blacklisted_directories(directories, rm_black_dirs_from_stored_dirs=True)[source]

Adds directories to be blacklisted. Blacklisted directories will not be returned or searched recursively when calling the collect_directories method.

directories may be a single instance or an iterable. Recommend passing in absolute paths, but method will try to convert to absolute paths based on the current working directory.

If remove_from_stored_directories is true, all directories will be removed from internal state.

add_blacklisted_filepaths(filepaths, remove_from_stored=True)[source]

Add filepaths to blacklisted filepaths. If remove_from_stored is True, any filepaths in internal state will be automatically removed.

add_blacklisted_plugins(plugins)[source]

add blacklisted plugins. plugins may be a single object or iterable.

add_file_filters(file_filters)[source]

Adds file_filters to the internal file filters. file_filters can be single object or iterable.

add_module_plugin_filters(module_plugin_filters)[source]

Adds module_plugin_filters to the internal module filters. May be a single object or an iterable.

Every module filters must be a callable and take in a list of plugins and their associated names.

add_plugin_directories(paths, except_blacklisted=True)[source]

Adds directories to the set of plugin directories.

directories may be either a single object or a iterable.

directories can be relative paths, but will be converted into absolute paths based on the current working directory.

if except_blacklisted is True all directories in that are blacklisted will be removed

add_plugin_filepaths(filepaths, except_blacklisted=True)[source]

Adds filepaths to internal state. Recommend passing in absolute filepaths. Method will attempt to convert to absolute paths if they are not already.

filepaths can be a single object or an iterable

If except_blacklisted is True, all filepaths that have been blacklisted will not be added.

add_plugins(plugins)[source]

Adds plugins to the internal state. plugins may be a single object or an iterable.

If the instance member instantiate_classes in the underlying member plugin_manager is True and the plugins have class instances in them, attempts to instatiate the classes. Default is True

This can be checked/changed by:

plugin_interface.plugin_manager.instantiate_classes

If the instance member unique_instances in the underlying member plugin_manager is True and duplicate instances are passed in, this method will not track the new instances internally. Default is True

This can be checked/changed by:

plugin_interface.plugin_manager.unique_instances
add_to_loaded_modules(modules)[source]

Manually add in modules to be tracked by the module manager.

modules may be a single object or an iterable.

get_blacklisted_directories()[source]

Returns the set of the blacklisted directories.

get_blacklisted_filepaths()[source]

Returns the blacklisted filepaths as a set object.

get_blacklisted_plugins()[source]

gets blacklisted plugins tracked in the internal state Returns a list object.

get_file_filters(filter_function=None)[source]

Gets the file filters. filter_function, can be a user defined filter. Should be callable and return a list.

get_instances(filter_function=<class 'pluginmanager.iplugin.IPlugin'>)[source]

Gets instances out of the internal state using the default filter supplied in filter_function. By default, it is the class IPlugin.

Can optionally pass in a list or tuple of classes in for filter_function which will accomplish the same goal.

lastly, a callable can be passed in, however it is up to the user to determine if the objects are instances or not.

get_loaded_modules()[source]

Returns all modules loaded by this instance.

get_module_plugin_filters(filter_function=None)[source]

Gets the internal module filters. Returns a list object.

If supplied, the filter_function should take in a single list argument and return back a list. filter_function is designed to given the option for a custom filter on the module filters.

get_plugin_directories()[source]

Returns the plugin directories in a set object

get_plugin_filepaths()[source]

returns the plugin filepaths tracked internally as a set object.

get_plugins(filter_function=None)[source]

Gets out the plugins from the internal state. Returns a list object.

If the optional filter_function is supplied, applies the filter function to the arguments before returning them. Filters should be callable and take a list argument of plugins.

remove_blacklisted_directories(directories)[source]

Attempts to remove the directories from the set of blacklisted directories. If a particular directory is not found in the set of blacklisted, method will continue on silently.

directories may be a single instance or an iterable. Recommend passing in absolute paths. Method will try to convert to an absolute path if it is not already using the current working directory.

remove_blacklisted_filepaths(filepaths)[source]

Removes filepaths from blacklisted filepaths. filepaths may be a single filepath or iterable of filepaths. recommend passing in absolute filepaths but method will attempt to convert to absolute filepaths based on current working directory.

remove_blacklisted_plugins(plugins)[source]

removes plugins from the blacklisted plugins. plugins may be a single object or iterable.

remove_file_filters(file_filters)[source]

Removes the file_filters from the internal state. file_filters can be a single object or an iterable.

remove_module_plugin_filters(module_plugin_filters)[source]

Removes module_plugin_filters from the internal module filters. If the filters are not found in the internal representation, the function passes on silently.

module_plugin_filters may be a single object or an iterable.

remove_plugin_directories(paths)[source]

Removes any directories from the set of plugin directories.

directories may be a single object or an iterable.

Recommend passing in all paths as absolute, but the method will attemmpt to convert all paths to absolute if they are not already based on the current working directory.

remove_plugin_filepaths(filepaths)[source]

Removes filepaths from internal state. Recommend passing in absolute filepaths. Method will attempt to convert to absolute paths if not passed in.

filepaths can be a single object or an iterable.

remove_plugins(plugins)[source]

removes plugins from the internal state

plugins may be a single object or an iterable.

set_blacklisted_directories(directories, rm_black_dirs_from_stored_dirs=True)[source]

Sets the directories to be blacklisted. Blacklisted directories will not be returned or searched recursively when calling collect_directories.

This will replace the previously stored set of blacklisted paths.

directories may be a single instance or an iterable. Recommend passing in absolute paths. Method will try to convert to absolute path based on current working directory.

set_blacklisted_filepaths(filepaths, remove_from_stored=True)[source]

Sets internal blacklisted filepaths to filepaths. If remove_from_stored is True, any filepaths in internal state will be automatically removed.

set_blacklisted_plugins(plugins)[source]

sets blacklisted plugins. plugins may be a single object or iterable.

set_file_filters(file_filters)[source]

Sets internal file filters to file_filters by tossing old state. file_filters can be single object or iterable.

set_module_plugin_filters(module_plugin_filters)[source]

Sets the internal module filters to module_plugin_filters module_plugin_filters may be a single object or an iterable.

Every module filters must be a callable and take in a list of plugins and their associated names.

set_plugin_directories(paths, except_blacklisted=True)[source]

Sets the plugin directories to directories. This will delete the previous state stored in self.plugin_directories in favor of the directories passed in.

directories may be either a single object or an iterable.

directories can contain relative paths but will be converted into absolute paths based on the current working directory.

if except_blacklisted is True all directories in blacklisted that are blacklisted will be removed

set_plugin_filepaths(filepaths, except_blacklisted=True)[source]

Sets internal state to filepaths. Recommend passing in absolute filepaths. Method will attempt to convert to absolute paths if they are not already.

filepaths can be a single object or an iterable.

If except_blacklisted is True, all filepaths that have been blacklisted will not be set.

set_plugins(plugins)[source]

sets plugins to the internal state. If the instance member instantiate_classes in the underlying member plugin_manager is True and the plugins have class instances in them, attempts to instatiate the classes. The default is True

This can be checked/changed by:

plugin_interface.plugin_manager.instantiate_classes

If the instance member unique_instances in the underlying member plugin_manager is True and duplicate instances are passed in, this method will not track the new instances internally. The default is True

This can be checked/changed by:

plugin_interface.plugin_manager.unique_instances
track_site_package_paths()[source]

A helper method to add all of the site packages tracked by python to the set of plugin directories.

NOTE that if using a virtualenv, there is an outstanding bug with the method used here. While there is a workaround implemented, when using a virutalenv this method WILL NOT track every single path tracked by python. See: https://github.com/pypa/virtualenv/issues/355