Straight Plugin API

Loaders

straight.plugin.loaders.unified_load(namespace, subclasses=None, recurse=False)

Provides a unified interface to both the module and class loaders, finding modules by default or classes if given a subclasses parameter.

class straight.plugin.loaders.Loader(*args, **kwargs)

Base loader class. Only used as a base-class for other loaders.

class straight.plugin.loaders.ModuleLoader(recurse=False)

Performs the work of locating and loading straight plugins.

This looks for plugins in every location in the import path.

class straight.plugin.loaders.ObjectLoader(recurse=False)

Loads classes or objects out of modules in a namespace, based on a provided criteria.

The load() method returns all objects exported by the module.

class straight.plugin.loaders.ClassLoader(recurse=False)

Loads classes out of plugin modules which are subclasses of a single given base class.

PluginManager

class straight.plugin.manager.PluginManager(plugins)
call(methodname, *args, **kwargs)

Call a common method on all the plugins, if it exists.

first(methodname, *args, **kwargs)

Call a common method on all the plugins, if it exists. Return the first result (the first non-None)

pipe(methodname, first_arg, *args, **kwargs)

Call a common method on all the plugins, if it exists. The return value of each call becomes the replaces the first argument in the given argument list to pass to the next.

Useful to utilize plugins as sets of filters.

produce(*args, **kwargs)

Produce a new set of plugins, treating the current set as plugin factories.