1
0
mirror of https://github.com/craigerl/aprsd.git synced 2024-11-10 10:33:31 -05:00

Merge pull request #17 from craigerl/fix_plugin

Reworked Plugin loading
This commit is contained in:
Walter A. Boring IV 2020-12-15 07:53:56 -05:00 committed by GitHub
commit ec140995c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 41 additions and 21 deletions

View File

@ -1,7 +1,6 @@
# The base plugin class
import abc
import fnmatch
import imp
import inspect
import json
import logging
@ -13,6 +12,7 @@ import time
import pluggy
import requests
import six
from thesmuggler import smuggle
from aprsd.fuzzyclock import fuzzy
@ -106,16 +106,10 @@ class PluginManager(object):
for path, subdirs, files in os.walk(dir_path):
for name in files:
if fnmatch.fnmatch(name, pattern):
found_module = imp.find_module(name[:-3], [path])
module = imp.load_module(
name, found_module[0], found_module[1], found_module[2]
)
LOG.debug("MODULE? '{}' '{}'".format(name, path))
module = smuggle("{}/{}".format(path, name))
for mem_name, obj in inspect.getmembers(module):
if (
inspect.isclass(obj)
and inspect.getmodule(obj) is module
and self.is_plugin(obj)
):
if inspect.isclass(obj) and self.is_plugin(obj):
self.obj_list.append(
{"name": mem_name, "obj": obj(self.config)}
)

View File

@ -7,3 +7,4 @@ pep8-naming
black
isort
Sphinx
thesmuggler

View File

@ -11,6 +11,7 @@ babel==2.9.0 # via sphinx
black==20.8b1 # via -r dev-requirements.in
certifi==2020.12.5 # via requests
chardet==3.0.4 # via requests
click==7.1.2 # via black
coverage==5.3 # via pytest-cov
distlib==0.3.1 # via virtualenv
docutils==0.16 # via sphinx
@ -26,17 +27,17 @@ markupsafe==1.1.1 # via jinja2
mccabe==0.6.1 # via flake8
mypy-extensions==0.4.3 # via black, mypy
mypy==0.790 # via -r dev-requirements.in
packaging==20.7 # via pytest, sphinx, tox
packaging==20.8 # via pytest, sphinx, tox
pathspec==0.8.1 # via black
pep8-naming==0.11.1 # via -r dev-requirements.in
pluggy==0.13.1 # via pytest, tox
py==1.9.0 # via pytest, tox
py==1.10.0 # via pytest, tox
pycodestyle==2.6.0 # via flake8
pyflakes==2.2.0 # via flake8
pygments==2.7.3 # via sphinx
pyparsing==2.4.7 # via packaging
pytest-cov==2.10.1 # via -r dev-requirements.in
pytest==6.1.2 # via -r dev-requirements.in, pytest-cov
pytest==6.2.0 # via -r dev-requirements.in, pytest-cov
pytz==2020.4 # via babel
regex==2020.11.13 # via black
requests==2.25.0 # via sphinx
@ -49,6 +50,7 @@ sphinxcontrib-htmlhelp==1.0.3 # via sphinx
sphinxcontrib-jsmath==1.0.1 # via sphinx
sphinxcontrib-qthelp==1.0.3 # via sphinx
sphinxcontrib-serializinghtml==1.1.4 # via sphinx
thesmuggler==1.0.1 # via -r dev-requirements.in
toml==0.10.2 # via black, pytest, tox
tox==3.20.1 # via -r dev-requirements.in
typed-ast==1.4.1 # via black, mypy

9
requirements.in Normal file
View File

@ -0,0 +1,9 @@
click
click-completion
imapclient
pluggy
pbr
pyyaml
six
requests
thesmuggler

View File

@ -1,8 +1,22 @@
click
click-completion
imapclient
pluggy
pbr
pyyaml
six
requests
#
# This file is autogenerated by pip-compile
# To update, run:
#
# pip-compile
#
certifi==2020.12.5 # via requests
chardet==3.0.4 # via requests
click-completion==0.5.2 # via -r requirements.in
click==7.1.2 # via -r requirements.in, click-completion
idna==2.10 # via requests
imapclient==2.1.0 # via -r requirements.in
jinja2==2.11.2 # via click-completion
markupsafe==1.1.1 # via jinja2
pbr==5.5.1 # via -r requirements.in
pluggy==0.13.1 # via -r requirements.in
pyyaml==5.3.1 # via -r requirements.in
requests==2.25.0 # via -r requirements.in
shellingham==1.3.2 # via click-completion
six==1.15.0 # via -r requirements.in, click-completion, imapclient
thesmuggler==1.0.1 # via -r requirements.in
urllib3==1.26.2 # via requests