Files
krowlog/src/plugins/__init__.py
Andreas Huber a640b35c87 rename ravenlog to krowlog
There is a database named RavenDB.
KrowLog starts with a K, which is a) distinctive and b) has an association to KDE.
2022-02-12 10:48:38 +01:00

26 lines
1017 B
Python

from inspect import isclass
from pkgutil import iter_modules
from pathlib import Path
from importlib import import_module
from src.pluginbase import PluginBase
# iterate through the modules in the current package
from src.pluginregistry import PluginRegistry
if False:
package_dir = Path(__file__).resolve().parent
for (_, module_name, _) in iter_modules([str(package_dir)]):
# import the module and iterate through its attributes
module = import_module(f"{__name__}.{module_name}")
print("module: %s" % module)
for attribute_name in dir(module):
if attribute_name == "PluginBase":
continue
attribute = getattr(module, attribute_name)
if isclass(attribute) and issubclass(attribute, PluginBase):
globals()[attribute_name] = attribute
PluginRegistry.register_plugin(attribute_name, attribute)
print("%s -> %s :: %s in %s" % (attribute_name, attribute, module_name, module))