mirror of
https://gitea.com/Lerking/XtendR.git
synced 2025-07-21 04:31:15 +02:00
40 lines
1.1 KiB
Python
40 lines
1.1 KiB
Python
import threading
|
|
import time
|
|
from xtendr.xtendrbase import XtendRBase
|
|
|
|
class ExamplePlugin(XtendRBase):
|
|
"""Example plugin implementation.
|
|
|
|
Example:
|
|
>>> plugin = ExamplePlugin()
|
|
>>> plugin.run("Hello!", 25)
|
|
Passed arguments 2:
|
|
Argument 0: Hello!
|
|
Argument 1: 25
|
|
ExamplePlugin is running!
|
|
>>> plugin.stop()
|
|
ExamplePlugin has stopped!
|
|
"""
|
|
def run(self, *args, **kwargs):
|
|
arglen = len(args)
|
|
keylen = len(kwargs)
|
|
if arglen > 0:
|
|
print(f"Passed arguments {arglen}:")
|
|
for idx, a in enumerate(args):
|
|
print(f"Argument {idx}: {a}")
|
|
if keylen > 0:
|
|
print(f"Keyword arguments passed {keylen}")
|
|
if not "test" in kwargs:
|
|
raise ValueError("Didn't get expected 'test' keyword!")
|
|
for kw in kwargs:
|
|
print(f"Argument {kw}: {kwargs[kw]}")
|
|
|
|
print("ExamplePlugin is running!")
|
|
|
|
def stop(self):
|
|
print("ExamplePlugin has stopped!")
|
|
|
|
def pre_load(self, callback):
|
|
time.sleep(5) # Indicate long running pre-load.
|
|
callback()
|