mirror of
https://github.com/wax911/plugin-architecture.git
synced 2025-07-21 04:21:03 +02:00
37 lines
856 B
Python
37 lines
856 B
Python
from logging import Logger
|
|
from typing import Optional, List
|
|
|
|
from model import Meta, Device
|
|
|
|
|
|
class IPluginRegistry(type):
|
|
plugin_registries: List[type] = list()
|
|
|
|
def __init__(cls, name, bases, attrs):
|
|
super().__init__(cls)
|
|
if name != 'PluginCore':
|
|
IPluginRegistry.plugin_registries.append(cls)
|
|
|
|
|
|
class PluginCore(object, metaclass=IPluginRegistry):
|
|
"""
|
|
Plugin core class
|
|
"""
|
|
|
|
meta: Optional[Meta]
|
|
|
|
def __init__(self, logger: Logger) -> None:
|
|
"""
|
|
Entry init block for plugins
|
|
:param logger: logger that plugins can make use of
|
|
"""
|
|
self._logger = logger
|
|
|
|
def invoke(self, **args) -> Device:
|
|
"""
|
|
Starts main plugin flow
|
|
:param args: possible arguments for the plugin
|
|
:return: a device for the plugin
|
|
"""
|
|
pass
|