vipr.core package¶
Submodules¶
vipr.core.abstractmodel module¶
vipr.core.config module¶
- vipr.core.config.handle_config(app, module, config)¶
vipr.core.exc module¶
vipr.core.filtermanager module¶
- class vipr.core.filtermanager.FilterManager(app)¶
Bases:
objectManages the filter system to define, get, run, etc filters within the the Cement Framework and applications Built on Cement (tm).
- define(name)¶
Define a filter namespace that the application and plugins can register filters in.
- Parameters:
name (str) – The name of the filter, stored as filters[‘name’]
- Raises:
cement.core.exc.FrameworkError – If the filter name is already defined
Example
from cement import App with App('myapp') as app: app.filter.define('my_filter_name')
- defined(filter_name)¶
Test whether a filter name is defined.
- Parameters:
filter_name (str) – The name of the filter. I.e.
my_filter_does_awesome_things.- Returns:
Trueif the filter is defined,Falseotherwise.- Return type:
Example
from cement import App with App('myapp') as app: app.filter.defined('some_filter_name'): # do something about it pass
- list()¶
List all defined filters.
- Returns:
List of registered filter labels.
- Return type:
filters (list)
- register(name, func, weight=0)¶
Register a function to a filter. The function will be called, in order of weight, when the filter is run.
- Parameters:
name (str) – The name of the filter to register too. I.e.
pre_setup,post_run, etc.func (function) – The function to register to the filter. This is an
*un-instantiated*
method (non-instance)
function. (simple)
- Keywork Args:
weight (int): The weight in which to order the filter function.
Example
from cement import App def my_filter_func(app): # do something with app? return True with App('myapp') as app: app.filter.define('my_filter_name') app.filter.register('my_filter_name', my_filter_func)
- run(name, *args, **kwargs)¶
Run all defined filters in the namespace.
- Parameters:
name (str) – The name of the filter function.
args (Tuple[Any, ...]) – Additional arguments to be passed to the filter functions.
(Dict[str (kwargs) – Additional keyword arguments to be passed to the filter functions.
Any] – Additional keyword arguments to be passed to the filter functions.
- Yields:
The result of each filter function executed.
- Raises:
cement.core.exc.FrameworkError – If the filter
nameis not defined
Example
from cement import App def my_filter_func(app): # do something with app? return True with App('myapp') as app: app.filter.define('my_filter_name') app.filter.register('my_filter_name', my_filter_func) for res in app.filter.run('my_filter_name', app): # do something with the result? pass
- vipr.core.filtermanager.LOG = <cement.utils.misc.MinimalLogger object>¶
Cement core filters module.
vipr.core.plugin_loader module¶
Plugin Discovery and Loading via Entry Points.
This module provides functionality to discover and load external VIPR plugins that have registered themselves via Python entry points in the ‘vipr.plugins’ group.
- Plugins can be enabled/disabled via configuration files by setting:
- plugin.{plugin_name}:
enabled: true/false
The configuration can be loaded via the VIPR_PLUGIN_CONFIG environment variable.
- vipr.core.plugin_loader.discover_and_load_external_plugins(app: App) None¶
Discover and load all installed packages that have registered themselves as ‘vipr.plugins’ entry points.
This function scans for Python packages that have defined entry points in the ‘vipr.plugins’ group and loads them by calling their registered load function.
Entry points are defined in a plugin’s pyproject.toml like this:
[project.entry-points.”vipr.plugins”] my_plugin = “vipr.plugins.my_plugin:load”
The framework will then call the ‘load(app)’ function of each discovered plugin.
- Parameters:
app – The Cement application instance
Example
>>> from cement import App >>> app = App('myapp') >>> discover_and_load_external_plugins(app) # Will discover and load all plugins registered in 'vipr.plugins' group
vipr.core.version module¶
Version information for VIPR Core.
The version is defined in pyproject.toml and read via importlib.metadata.