Compare commits

5 Commits
main ... 0.0.1

Author SHA1 Message Date
e74b780017 Added manager and register. /JL 2024-07-17 18:50:47 +02:00
59fc0ef000 Added plugin relay metaclass. /JL 2024-07-17 18:23:00 +02:00
64f5e4207e Updated makefile. /JL 2024-07-15 17:58:29 +02:00
0b78012951 Updated wakatime. /JL 2024-07-15 17:48:10 +02:00
5d4e5809af Added file etc. /JL 2024-07-14 22:03:27 +02:00
8 changed files with 54 additions and 5 deletions

View File

@@ -3,7 +3,7 @@
[![forthebadge made-with-python](http://ForTheBadge.com/images/badges/made-with-python.svg)](https://www.python.org/) [![forthebadge made-with-python](http://ForTheBadge.com/images/badges/made-with-python.svg)](https://www.python.org/)
Coding time for this reposotory.</br> Coding time for this reposotory.</br>
[![wakatime](https://wakatime.com/badge/user/d43f2852-fd6f-45b4-b713-558ad18204d4/project/dcf411f9-6d3e-4b14-9290-5ed419cf4012.svg)](https://wakatime.com/badge/user/d43f2852-fd6f-45b4-b713-558ad18204d4/project/dcf411f9-6d3e-4b14-9290-5ed419cf4012) [![wakatime](https://wakatime.com/badge/user/d43f2852-fd6f-45b4-b713-558ad18204d4/project/4e75f1fd-6bb3-40d6-9b84-e69a9cc0317c.svg)](https://wakatime.com/badge/user/d43f2852-fd6f-45b4-b713-558ad18204d4/project/4e75f1fd-6bb3-40d6-9b84-e69a9cc0317c)
See the wiki for usage and examples. See the wiki for usage and examples.
[pluginlib wiki page](https://gitpot-lerking.servehttp.com/Lerking/pluginlib/wiki) [pluginlib wiki page](https://gitpot-lerking.servehttp.com/Lerking/pluginlib/wiki)

View File

@@ -1,6 +1,6 @@
dist: dist:
python3 setup.py sdist python setup.py sdist
install: install:
cd dist cd dist
python3 -m pip install tcxmodeler-0.0.4.tar.gz python -m pip install pluginlib-0.0.1.tar.gz

View File

@@ -0,0 +1,4 @@
from . import pluginlib_init
from . import pluginlib_manager
from . import pluginlib_register
from . import pluginlib_relay

View File

@@ -1,3 +1,3 @@
[pluginlib] [pluginlib]
build = 2 build = 6

View File

@@ -0,0 +1,2 @@
import yaml

View File

View File

@@ -0,0 +1,19 @@
import importlib.metadata as importlib_metadata
def register_plugin(name, namespace, entry_point) -> None:
"""Registers a plugin dynamically without needing to install as a package.
Args:
name (str): Name of plugin to be referenced.
namespace (str): Name of plugin namespace.
entry_point (str): Entry point in the form: some.module:some.attr
"""
ep = importlib_metadata.EntryPoint(name, entry_point, namespace)
e = ExtensionManager(namespace)
if namespace in e.ENTRY_POINT_CACHE:
entry_points = e.ENTRY_POINT_CACHE.get(namespace)
if name not in [entry_point.name for entry_point in entry_points]:
entry_points.append(ep)
e.ENTRY_POINT_CACHE[namespace] = entry_points
else:
e.ENTRY_POINT_CACHE[namespace] = [ep]
ep.load()

View File

@@ -0,0 +1,24 @@
from abc import ABCMeta, abstractmethod
class RelayBase(metaclass=ABCMeta):
"""Base class for relay plugins"""
def __init__(self) -> None:
"""Define base attributes."""
self.connected = False
@abstractmethod
def disconnect(self) -> None:
"""Disconnects relay."""
@abstractmethod
def connect(self) -> None:
"""Connects relay."""
@abstractmethod
def reconnect(self, seconds: int) -> None:
"""Disconnects for specified time and reconnects.
Args:
seconds (int): Amount of time to sleep between disconnect and connect.
"""