pcvs.plugins package

Subpackages

Module contents

class pcvs.plugins.Collection[source]

Bases: object

The Plugin Manager.

Consists in a dict of passes, eaching being initialized to None. Only one plugin can be set to a given step (the last loaded).

constructor method

activate_plugin(name)[source]

Flag a plugin as active, meaning it will be called when the pass is reached.

Parameters:

name (str) – the plugin name.

Return type:

None

exist_plugin(name)[source]

Check if a plugin already exist.

Return type:

bool

has_enabled_step(step, method='run')[source]

Check if a given pass is enabled.

Parameters:
  • step (Step) – the pass

  • method (str) – the name of the method to call in the plugin (default to run).

Return type:

bool

Returns:

True if defined, False otherwise

invoke_plugins(step, method='run', *args, **kwargs)[source]

Load the appropriate plugin, given a step.

Parameters:
  • step (Step) – the step to target

  • method (str) – the name of the method to call in the plugin module (default to run).

  • args (list) – variadic arguments to pass to the plugin

  • kwargs (dict) – variadic arguments to pass to the plugin

Raises:

PluginException.BadStepError – wrong Step value

Return type:

Any

Returns:

the same return value as returned by the run() plugin method.

# noqa: DAR401 # noqa: DAR402

nb_plugins_for(step)[source]

Count the number of possible plugins for a given step.

Parameters:

step (Step) – the step to check

Return type:

int

Returns:

the number of plugins

register_default_plugins()[source]

Detect plugins stored in default places.

Return type:

None

register_plugin_by_dir(pkgpath, activate=False)[source]

From a prefix directory, load any plugin defined in it.

Mainly used to load any Plugin classes defined in a directory. The directory must be layout’d as a PYTHON package.

Parameters:
  • pkgpath (str) – prefix path

  • activate (bool) – Should the plugin be activated.

Return type:

None

register_plugin_by_file(modpath, activate=False)[source]

Based on a filepath (as a module dir), load plugins contained in it.

Parameters:
  • modpath (Path) – valid python filepath

  • activate (bool) – should the plugin be activated.

Return type:

None

register_plugin_by_module(name, mod, activate=False)[source]

Based on a module name, load any defined plugin.

mod must be a valid PYTHON module name.

Parameters:
  • name (str) – the module name to load

  • mod (ModuleType) – the python module object

  • activate (bool) – Should the plugin be activated.

Return type:

None

register_plugin_by_package(pkgname, activate=False)[source]

Based on a package name, load any plugin defined into it.

Parameters:
  • pkgname (str) – package name, valid under current PYTHON env.

  • activate (bool) – Should the plugin be activated.

Raises:

PluginException.LoadError – Error while importing the package

Return type:

None

# noqa: DAR401 # noqa: DAR402

show_enabled_plugins()[source]

Display the list of loaded plugins.

Return type:

None

show_plugins()[source]

Display plugin context to stdout.

Return type:

None

try_invoke_plugins(step, method='run', *args, **kwargs)[source]
Return type:

Any

class pcvs.plugins.Plugin[source]

Bases: object

Base class to inherit from when implementing a plugin.

This class should be used by any defined plugin and:

  • the attribute step should be set to a possible value defined by Plugin.Step.

  • implement the function run(self, *args, **kwargs)

List of possible values is defined by the per-step API.

Raises:

PluginException.NotImplementedError – if run() method is not overridden

constructor method.

class Step(*values)[source]

Bases: Enum

Possible pass a plugin can be loaded into.

*_EVAL steps describe plugin passes where the function outcome can infer with the actual workflow.

END_AFTER = 18
END_BEFORE = 17
INVALID = -1
SCHED_AFTER = 16
SCHED_BEFORE = 7
SCHED_JOB_EVAL = 10
SCHED_PUBLISH_AFTER = 15
SCHED_PUBLISH_BEFORE = 13
SCHED_PUBLISH_WRITE = 14
SCHED_SET_AFTER = 11
SCHED_SET_BEFORE = 8
SCHED_SET_EVAL = 9
START_AFTER = 1
START_BEFORE = 0
TDESC_AFTER = 5
TDESC_BEFORE = 3
TEST_EVAL = 4
TEST_RESULT_EVAL = 12
TFILE_AFTER = 6
TFILE_BEFORE = 2
abstractmethod run(*args, **kwargs)[source]

To-be-overridden method.

step = -1