Major completion provider overhaul; pluigin load and pattern improvements; css overhaul/cleanup; source view state modes added
This commit is contained in:
@@ -55,7 +55,7 @@ class PluginsController(ControllerBase, PluginsControllerMixin, PluginReloadMixi
|
||||
for file in os.listdir(path):
|
||||
_path = os.path.join(path, file)
|
||||
if os.path.isdir(_path):
|
||||
self.collect_search_locations(_path, locations)
|
||||
self._collect_search_locations(_path, locations)
|
||||
|
||||
def _load_plugins(
|
||||
self,
|
||||
@@ -70,7 +70,7 @@ class PluginsController(ControllerBase, PluginsControllerMixin, PluginReloadMixi
|
||||
try:
|
||||
target = join(path, "plugin.py")
|
||||
if not os.path.exists(target):
|
||||
raise InvalidPluginException("Invalid Plugin Structure: Plugin doesn't have 'plugin.py'. Aboarting load...")
|
||||
raise PluginsControllerException("Invalid Plugin Structure: Plugin doesn't have 'plugin.py'. Aboarting load...")
|
||||
|
||||
module = self._load_plugin_module(path, folder, target)
|
||||
|
||||
|
||||
@@ -32,11 +32,8 @@ class ManifestManager:
|
||||
|
||||
for path, folder in [
|
||||
[join(self._plugins_path, item), item]
|
||||
if
|
||||
os.path.isdir( join(self._plugins_path, item) )
|
||||
else
|
||||
None
|
||||
for item in os.listdir(self._plugins_path)
|
||||
if os.path.isdir( join(self._plugins_path, item) )
|
||||
]:
|
||||
self.load(folder, path)
|
||||
|
||||
|
||||
7
src/plugins/plugin_types/__init__.py
Normal file
7
src/plugins/plugin_types/__init__.py
Normal file
@@ -0,0 +1,7 @@
|
||||
"""
|
||||
Plugin Types Module
|
||||
"""
|
||||
|
||||
from .plugin_base import PluginBase
|
||||
from .plugin_ui import PluginUI
|
||||
from .plugin_code import PluginCode
|
||||
49
src/plugins/plugin_types/plugin_base.py
Normal file
49
src/plugins/plugin_types/plugin_base.py
Normal file
@@ -0,0 +1,49 @@
|
||||
# Python imports
|
||||
|
||||
# Lib imports
|
||||
|
||||
# Application imports
|
||||
from libs.dto.base_event import BaseEvent
|
||||
|
||||
from ..plugin_context import PluginContext
|
||||
|
||||
|
||||
|
||||
class PluginBaseException(Exception):
|
||||
...
|
||||
|
||||
|
||||
|
||||
class PluginBase:
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(PluginBase, self).__init__(*args, **kwargs)
|
||||
|
||||
self.plugin_context: PluginContext = None
|
||||
|
||||
|
||||
def _controller_message(self, event: BaseEvent):
|
||||
raise PluginBaseException("Plugin Base '_controller_message' must be overriden by Plugin")
|
||||
|
||||
def load(self):
|
||||
raise PluginBaseException("Plugin Base 'load' must be overriden by Plugin")
|
||||
|
||||
def run(self):
|
||||
raise PluginBaseException("Plugin Base 'run' must be overriden by Plugin")
|
||||
|
||||
def requests_ui_element(self, element_id: str):
|
||||
raise PluginBaseException("Plugin Base 'requests_ui_element' must be overriden by Plugin")
|
||||
|
||||
def message(self, event: BaseEvent):
|
||||
raise PluginBaseException("Plugin Base 'message' must be overriden by Plugin")
|
||||
|
||||
def message_to(self, name: str, event: BaseEvent):
|
||||
raise PluginBaseException("Plugin Base 'message_to' must be overriden by Plugin")
|
||||
|
||||
def message_to_selected(self, names: list[str], event: BaseEvent):
|
||||
raise PluginBaseException("Plugin Base 'message_to_selected' must be overriden by Plugin")
|
||||
|
||||
def emit(self, event_type: str, data: tuple = ()):
|
||||
raise PluginBaseException("Plugin Base 'emit' must be overriden by Plugin")
|
||||
|
||||
def emit_and_await(self, event_type: str, data: tuple = ()):
|
||||
raise PluginBaseException("Plugin Base 'emit_and_await' must be overriden by Plugin")
|
||||
41
src/plugins/plugin_types/plugin_code.py
Normal file
41
src/plugins/plugin_types/plugin_code.py
Normal file
@@ -0,0 +1,41 @@
|
||||
# Python imports
|
||||
|
||||
# Lib imports
|
||||
|
||||
# Application imports
|
||||
from libs.dto.base_event import BaseEvent
|
||||
|
||||
from ..plugin_context import PluginContext
|
||||
from .plugin_base import PluginBase
|
||||
|
||||
|
||||
|
||||
class PluginCodeException(Exception):
|
||||
...
|
||||
|
||||
|
||||
|
||||
class PluginCode(PluginBase):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(PluginCode, self).__init__(*args, **kwargs)
|
||||
|
||||
self.plugin_context: PluginContext = None
|
||||
|
||||
|
||||
def _controller_message(self, event: BaseEvent):
|
||||
raise PluginCodeException("Plugin Code '_controller_message' must be overriden by Plugin")
|
||||
|
||||
def load(self):
|
||||
raise PluginCodeException("Plugin Code 'load' must be overriden by Plugin")
|
||||
|
||||
def run(self):
|
||||
raise PluginCodeException("Plugin Code 'run' must be overriden by Plugin")
|
||||
|
||||
def message(self, event: BaseEvent):
|
||||
return self.plugin_context.message(event)
|
||||
|
||||
def message_to(self, name: str, event: BaseEvent):
|
||||
return self.plugin_context.message_to(name, event)
|
||||
|
||||
def message_to_selected(self, names: list[str], event: BaseEvent):
|
||||
return self.plugin_context.message_to_selected(names, event)
|
||||
@@ -5,30 +5,31 @@
|
||||
# Application imports
|
||||
from libs.dto.base_event import BaseEvent
|
||||
|
||||
from .plugin_context import PluginContext
|
||||
from ..plugin_context import PluginContext
|
||||
from .plugin_base import PluginBase
|
||||
|
||||
|
||||
|
||||
class PluginBaseException(Exception):
|
||||
class PluginCodeException(Exception):
|
||||
...
|
||||
|
||||
|
||||
|
||||
class PluginBase:
|
||||
class PluginUI(PluginBase):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(PluginBase, self).__init__(*args, **kwargs)
|
||||
super(PluginUI, self).__init__(*args, **kwargs)
|
||||
|
||||
self.plugin_context: PluginContext = None
|
||||
|
||||
|
||||
def _controller_message(self, event: BaseEvent):
|
||||
raise PluginBaseException("Plugin Base '_controller_message' must be overriden by Plugin")
|
||||
raise PluginCodeException("Plugin UI '_controller_message' must be overriden by Plugin")
|
||||
|
||||
def load(self):
|
||||
raise PluginBaseException("Plugin Base 'load' must be overriden by Plugin")
|
||||
raise PluginCodeException("Plugin UI 'load' must be overriden by Plugin")
|
||||
|
||||
def run(self):
|
||||
raise PluginBaseException("Plugin Base 'run' must be overriden by Plugin")
|
||||
raise PluginCodeException("Plugin UI 'run' must be overriden by Plugin")
|
||||
|
||||
def requests_ui_element(self, element_id: str):
|
||||
return self.plugin_context.requests_ui_element(element_id)
|
||||
@@ -6,6 +6,10 @@
|
||||
|
||||
|
||||
|
||||
class InvalidPluginException(Exception):
|
||||
...
|
||||
|
||||
|
||||
|
||||
class PluginsControllerMixin:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user