-
Notifications
You must be signed in to change notification settings - Fork 0
Plugins
PyPluginizer organizes plugins into core and user-specific categories, providing flexibility for customization.
PyPluginizer/
│
├── src/
│ └── plugins/
│ ├── core/ # Core plugins managed by the framework.
│ │ └── plugin
│ │ └── DEPENDENCY
│ │ └── VERSION
│ │ └── __init__.py
│ │ └── plugin.py
│ ├── users/ # User-created plugins for extending functionality.
│ │ └── plugin
│ │ └── DEPENDENCY
│ │ └── VERSION
│ │ └── __init__.py
│ │ └── plugin.pyFound in ./src/plugins/core, these are fundamental components of the framework, handling essential functions.
Located in ./src/plugins/users, these allow users to extend the framework's functionality.
To create a plugin for PyPluginizer, follow these steps:
-
Create Plugin File: Inside the relevant directory (./src/plugins/core for core plugins or ./src/plugins/users for user plugins), create a new Python file (e.g., my_plugin.py).
-
Define Plugin Class: Write a class that implements required plugin methods, init(), execute(), and process_results(). This ensures the plugin integrates with PyPluginizer's lifecycle.
-
Hook Functionality: Add specific logic or functionality in your plugin's process_results() method.
-
Metadata: Ensure each plugin has metadata to identify its purpose, version, and dependencies.
-
Register Plugin: PyPluginizer automatically registers plugins based on their directory. Ensure the directory structure matches the framework's expectations.
Example:
# -*- coding: utf-8 -*-
class Test:
def __init__(self, logger, hooks=None, **kwargs):
# Assign the logger to an instance variable
self.logger = logger
# Assign the hooks to an instance variable
self.hooks = hooks
# Assign each value from kwargs to an instance variable
for key, value in kwargs.items():
setattr(self, key, value)
def execute(self):
self.logger.info("Executing plugin")
def process_results(self):
self.logger.info("Processing results for plugin")
self.hooks["json"].trigger()