10 Commits
3 changed files with 21 additions and 7 deletions
+8 -3
View File
@@ -1,8 +1,13 @@
dist: dist:
python -m build python -m build
test: test:
twine upload --repository testpypi /dist twine upload --repository testpypi dist/*
publish: publish:
twine upload --repository pypi /dist twine upload --repository pypi dist/*
all:
$(dist)
$(test)
$(publish)
+1 -1
View File
@@ -3,7 +3,7 @@ if __name__ == "__main__":
setup( setup(
name="XtendR", name="XtendR",
version="0.0.7", version="0.1.2",
packages=find_packages(), packages=find_packages(),
install_requires=[], install_requires=[],
author="Jan Lerking", author="Jan Lerking",
+12 -3
View File
@@ -4,11 +4,15 @@ import os
import json import json
from xtendr.xtendrbase import XtendRBase from xtendr.xtendrbase import XtendRBase
__version__ = "0.1.2"
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.2
>>> 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!
@@ -17,16 +21,20 @@ class XtendRSystem:
>>> system.detach("example_plugin") >>> system.detach("example_plugin")
Detached plugin 'example_plugin'. Detached plugin 'example_plugin'.
""" """
def __init__(self): def __init__(self, pluginpath = "plugins"):
self.pluginspath = pluginpath
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:
print(f"Plugin '{name}' is already attached.") print(f"Plugin '{name}' is already attached.")
return return
plugin_path = os.path.join(os.getcwd(), "plugins", name) plugin_path = os.path.join(os.getcwd(), self.pluginpath, name)
info_path = os.path.join(plugin_path, name + ".json") info_path = os.path.join(plugin_path, name + ".json")
print(plugin_path + "\n" + info_path) print(plugin_path + "\n" + info_path)
@@ -55,7 +63,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: