Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8c19c4a97b | ||
|
|
c7662a5d47 |
@@ -4,11 +4,15 @@ import os
|
|||||||
import json
|
import json
|
||||||
from xtendr.xtendrbase import XtendRBase
|
from xtendr.xtendrbase import XtendRBase
|
||||||
|
|
||||||
|
__version__ = "0.1.0"
|
||||||
|
|
||||||
class XtendRSystem:
|
class XtendRSystem:
|
||||||
"""Plugin system to manage plugins.
|
"""Plugin system to manage plugins.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
>>> system = XtendRSystem()
|
>>> system = XtendRSystem()
|
||||||
|
>>> system.version()
|
||||||
|
XtendR v0.1.0
|
||||||
>>> system.attach("example_plugin") # Assuming 'example_plugin/example_plugin.json' exists
|
>>> system.attach("example_plugin") # Assuming 'example_plugin/example_plugin.json' exists
|
||||||
>>> system.run("example_plugin")
|
>>> system.run("example_plugin")
|
||||||
ExamplePlugin is running!
|
ExamplePlugin is running!
|
||||||
@@ -20,6 +24,9 @@ class XtendRSystem:
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.plugins = {}
|
self.plugins = {}
|
||||||
|
|
||||||
|
def version(self) -> str:
|
||||||
|
return "XtendR v" + __version__
|
||||||
|
|
||||||
def attach(self, name: str) -> None:
|
def attach(self, name: str) -> None:
|
||||||
"""Dynamically load a plugin from its folder."""
|
"""Dynamically load a plugin from its folder."""
|
||||||
if name in self.plugins:
|
if name in self.plugins:
|
||||||
@@ -55,7 +62,8 @@ class XtendRSystem:
|
|||||||
self.plugins[name] = {
|
self.plugins[name] = {
|
||||||
'instance': instance,
|
'instance': instance,
|
||||||
'running': False,
|
'running': False,
|
||||||
'info': plugin_info
|
'info': plugin_info,
|
||||||
|
'autorun': False
|
||||||
}
|
}
|
||||||
print(f"Attached plugin '{name}'.")
|
print(f"Attached plugin '{name}'.")
|
||||||
except (ModuleNotFoundError, json.JSONDecodeError, AttributeError) as e:
|
except (ModuleNotFoundError, json.JSONDecodeError, AttributeError) as e:
|
||||||
|
|||||||
Reference in New Issue
Block a user