tuxemon.plugin module

class tuxemon.plugin.Plugin(name, module)[source]

Bases: Generic[T]

name
plugin_object
class tuxemon.plugin.PluginManager[source]

Bases: object

Yapsy semi-compatible plugin manager.

collectPlugins()[source]

Collect the plugins from the folders.

Return type:

None

getAllPlugins(*, interface)[source]

Get a sequence of loaded plugins.

Parameters:

interface (Type[InterfaceValue]) – Superclass or protocol of the returned classes.

Returns:

Sequence of plugins loaded.

Return type:

Sequence[Plugin[Type[InterfaceValue]]]

setPluginPlaces(plugin_folders)[source]

Set the locations where to look for plugins.

Parameters:

plugin_folders (Sequence[str]) – Sequence of folders that might contain plugins.

Return type:

None

class tuxemon.plugin.PluginObject(*args, **kwargs)[source]

Bases: Protocol

name: ClassVar[str]
tuxemon.plugin.get_available_classes(plugin_manager, *, interface)[source]

Gets the available classes in a plugin manager.

Parameter:

plugin_manager: Plugin manager with modules already loaded. interface: Superclass or protocol of the returned classes.

Returns:

Sequence of loaded classes.

Parameters:
  • plugin_manager (PluginManager) –

  • interface (Type[InterfaceValue]) –

Return type:

Sequence[Type[InterfaceValue]]

tuxemon.plugin.load_directory(plugin_folder)[source]

Loads and imports a directory of plugins.

Parameters:

plugin_folder (str) – The folder where to look for plugin files.

Returns:

A plugin manager, with the modules already loaded.

Return type:

PluginManager

tuxemon.plugin.load_plugins(path: str, category: str = 'plugins') Mapping[str, Type[PluginObject]][source]
tuxemon.plugin.load_plugins(path: str, category: str = 'plugins', *, interface: Type[InterfaceValue]) Mapping[str, Type[InterfaceValue]]

Load classes using plugin system.

Parameters:
  • path – Location of the modules to load.

  • category – Optional string for debugging info.

  • interface – Superclass or protocol of the returned classes. If no class is given, they are only required to have a name attribute.

Returns:

A dictionary mapping the name attribute of each class to the class itself.