From 34ba757bc6096f3cf1ccd7e0d3e175578067bb14 Mon Sep 17 00:00:00 2001 From: Jan Lerking Date: Thu, 27 Mar 2025 09:35:29 +0100 Subject: [PATCH] Added plugin.run() with arguments. /JL --- example.py | 6 +++++- plugins/example_plugin/example_plugin.py | 11 +++++++++-- setup.py | 2 +- xtendr/xtendrbase.py | 2 +- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/example.py b/example.py index 8625ffb..f34bfde 100644 --- a/example.py +++ b/example.py @@ -16,6 +16,10 @@ if __name__ == "__main__": """ system = XtendRSystem() system.attach("example_plugin") # Assuming 'example_plugin/plugin_info.json' exists - system.run("example_plugin") + system.run("example_plugin", "Hello!") + system.stop("example_plugin") + system.run("example_plugin", 25) + system.stop("example_plugin") + system.run("example_plugin", "Hello!", 25) system.stop("example_plugin") system.detach("example_plugin") \ No newline at end of file diff --git a/plugins/example_plugin/example_plugin.py b/plugins/example_plugin/example_plugin.py index 227a0c7..516abd7 100644 --- a/plugins/example_plugin/example_plugin.py +++ b/plugins/example_plugin/example_plugin.py @@ -5,12 +5,19 @@ class ExamplePlugin(XtendRBase): Example: >>> plugin = ExamplePlugin() - >>> plugin.run() + >>> plugin.run("Hello!", 25) + Passed arguments 2: + Argument 0: Hello! + Argument 1: 25 ExamplePlugin is running! >>> plugin.stop() ExamplePlugin has stopped! """ - def run(self): + def run(self, *args): + print(f"Passed arguments {len(args)}:") + for idx, a in enumerate(args): + print(f"Argument {idx}: {a}") + print("ExamplePlugin is running!") def stop(self): diff --git a/setup.py b/setup.py index e88dad6..4e0294c 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ if __name__ == "__main__": setup( name="XtendR", - version="0.1.3", + version="0.2.0", packages=find_packages(), install_requires=[], author="Jan Lerking", diff --git a/xtendr/xtendrbase.py b/xtendr/xtendrbase.py index 316bb55..e7f2e30 100644 --- a/xtendr/xtendrbase.py +++ b/xtendr/xtendrbase.py @@ -17,7 +17,7 @@ class XtendRBase(ABC): Stopping TestPlugin """ @abstractmethod - def run(self): + def run(self, *args): pass @abstractmethod