pcvs.plugins package
Subpackages
Module contents
- class pcvs.plugins.Collection[source]
Bases:
objectThe 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
- has_enabled_step(step, method='run')[source]
Check if a given pass is enabled.
- Parameters:
step (
Step) – the passmethod (
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 targetmethod (
str) – the name of the method to call in the plugin module (default to run).args (
list) – variadic arguments to pass to the pluginkwargs (
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_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 pathactivate (
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 filepathactivate (
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 loadmod (
ModuleType) – the python module objectactivate (
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
- class pcvs.plugins.Plugin[source]
Bases:
objectBase class to inherit from when implementing a plugin.
This class should be used by any defined plugin and:
the attribute
stepshould be set to a possible value defined byPlugin.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:
EnumPossible pass a plugin can be loaded into.
*_EVALsteps 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
- step = -1