Store plugin module paths as variables

This commit is contained in:
MinchinWeb 2021-10-11 14:20:13 -06:00
parent 159ef25248
commit fe32e0bc07

View file

@ -21,30 +21,36 @@ i.e. it is the collection of code that allows plugins to deal with themselves.
import importlib import importlib
import pkgutil import pkgutil
import jrnl.contrib.exporter INTERNAL_EXPORTER_CLASS_PATH = "jrnl.plugins.exporter"
import jrnl.contrib.importer INTERNAL_IMPORTER_CLASS_PATH = "jrnl.plugins.importer"
import jrnl.plugins.exporter EXTERNAL_EXPORTER_CLASS_PATH = "jrnl.contrib.exporter"
import jrnl.plugins.importer EXTERNAL_IMPORTER_CLASS_PATH = "jrnl.contrib.importer"
__internal_exporter_class = importlib.import_module(INTERNAL_EXPORTER_CLASS_PATH)
__internal_importer_class = importlib.import_module(INTERNAL_IMPORTER_CLASS_PATH)
__external_exporter_class = importlib.import_module(EXTERNAL_EXPORTER_CLASS_PATH)
__external_importer_class = importlib.import_module(EXTERNAL_IMPORTER_CLASS_PATH)
__exporters_builtin = list( __exporters_builtin = list(
pkgutil.iter_modules( pkgutil.iter_modules(
jrnl.plugins.exporter.__path__, jrnl.plugins.exporter.__name__ + "." __internal_exporter_class.__path__, __internal_exporter_class.__name__ + "."
) )
) )
__exporters_contrib = list( __exporters_contrib = list(
pkgutil.iter_modules( pkgutil.iter_modules(
jrnl.contrib.exporter.__path__, jrnl.contrib.exporter.__name__ + "." __external_exporter_class.__path__, __external_exporter_class.__name__ + "."
) )
) )
__importers_builtin = list( __importers_builtin = list(
pkgutil.iter_modules( pkgutil.iter_modules(
jrnl.plugins.importer.__path__, jrnl.plugins.importer.__name__ + "." __internal_importer_class.__path__, __internal_importer_class.__name__ + "."
) )
) )
__importers_contrib = list( __importers_contrib = list(
pkgutil.iter_modules( pkgutil.iter_modules(
jrnl.contrib.importer.__path__, jrnl.contrib.importer.__name__ + "." __external_importer_class.__path__, __external_importer_class.__name__ + "."
) )
) )