Files
swingmusic-extended/swingmusic/plugins/__init__.py
T
cwilvx 86fabcd5e3 modularize src
+ merge main.py and manage.py
+ move start logic to swingmusic/__main__.py
+ add a run.py on the project root
2025-05-25 20:35:54 +03:00

31 lines
643 B
Python

class Plugin:
"""
Class that all plugins should inherit from
"""
def __init__(self, name: str, description: str) -> None:
self.enabled = False
self.name = name
self.description = description
def set_active(self, state: bool):
self.enabled = state
def plugin_method(func):
"""
A decorator that prevents execution if the plugin is disabled.
Should be used on all plugin methods
"""
def wrapper(*args, **kwargs):
plugin: Plugin = args[0]
if plugin.enabled:
return func(*args, **kwargs)
else:
return
return wrapper