31 lines
749 B
Python
31 lines
749 B
Python
|
|
"""
|
||
|
|
Decorators for plugin registration and management.
|
||
|
|
|
||
|
|
This module provides convenient decorators for registering plugins.
|
||
|
|
"""
|
||
|
|
|
||
|
|
from typing import Type, Optional
|
||
|
|
from .registry import plugin_registry
|
||
|
|
from .base import BasePlugin
|
||
|
|
|
||
|
|
|
||
|
|
def register_plugin(name: Optional[str] = None):
|
||
|
|
"""
|
||
|
|
Decorator to register a plugin class.
|
||
|
|
|
||
|
|
Args:
|
||
|
|
name: Optional plugin name (uses class name if not provided)
|
||
|
|
|
||
|
|
Returns:
|
||
|
|
Decorator function
|
||
|
|
|
||
|
|
Example:
|
||
|
|
@register_plugin("my_processor")
|
||
|
|
class MyProcessor(ProcessorPlugin):
|
||
|
|
pass
|
||
|
|
"""
|
||
|
|
def decorator(plugin_class: Type[BasePlugin]) -> Type[BasePlugin]:
|
||
|
|
plugin_registry.register(plugin_class, name)
|
||
|
|
return plugin_class
|
||
|
|
|
||
|
|
return decorator
|