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

View File

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

View File

@ -11,6 +11,7 @@ babel==2.9.0 # via sphinx
black==20.8b1 # via -r dev-requirements.in black==20.8b1 # via -r dev-requirements.in
certifi==2020.12.5 # via requests certifi==2020.12.5 # via requests
chardet==3.0.4 # via requests chardet==3.0.4 # via requests
click==7.1.2 # via black
coverage==5.3 # via pytest-cov coverage==5.3 # via pytest-cov
distlib==0.3.1 # via virtualenv distlib==0.3.1 # via virtualenv
docutils==0.16 # via sphinx docutils==0.16 # via sphinx
@ -26,17 +27,17 @@ markupsafe==1.1.1 # via jinja2
mccabe==0.6.1 # via flake8 mccabe==0.6.1 # via flake8
mypy-extensions==0.4.3 # via black, mypy mypy-extensions==0.4.3 # via black, mypy
mypy==0.790 # via -r dev-requirements.in 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 pathspec==0.8.1 # via black
pep8-naming==0.11.1 # via -r dev-requirements.in pep8-naming==0.11.1 # via -r dev-requirements.in
pluggy==0.13.1 # via pytest, tox 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 pycodestyle==2.6.0 # via flake8
pyflakes==2.2.0 # via flake8 pyflakes==2.2.0 # via flake8
pygments==2.7.3 # via sphinx pygments==2.7.3 # via sphinx
pyparsing==2.4.7 # via packaging pyparsing==2.4.7 # via packaging
pytest-cov==2.10.1 # via -r dev-requirements.in 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 pytz==2020.4 # via babel
regex==2020.11.13 # via black regex==2020.11.13 # via black
requests==2.25.0 # via sphinx 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-jsmath==1.0.1 # via sphinx
sphinxcontrib-qthelp==1.0.3 # via sphinx sphinxcontrib-qthelp==1.0.3 # via sphinx
sphinxcontrib-serializinghtml==1.1.4 # 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 toml==0.10.2 # via black, pytest, tox
tox==3.20.1 # via -r dev-requirements.in tox==3.20.1 # via -r dev-requirements.in
typed-ast==1.4.1 # via black, mypy 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 # This file is autogenerated by pip-compile
imapclient # To update, run:
pluggy #
pbr # pip-compile
pyyaml #
six certifi==2020.12.5 # via requests
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