From 2ce8d7d4b1b04dfeb1b57ca19ed134b629f17f68 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sun, 26 Sep 2021 22:20:24 +0200 Subject: [PATCH] removing unneeded double --- InvenTree/InvenTree/plugins.py | 43 ---------------------------------- 1 file changed, 43 deletions(-) delete mode 100644 InvenTree/InvenTree/plugins.py diff --git a/InvenTree/InvenTree/plugins.py b/InvenTree/InvenTree/plugins.py deleted file mode 100644 index 8da725bf9c..0000000000 --- a/InvenTree/InvenTree/plugins.py +++ /dev/null @@ -1,43 +0,0 @@ -# -*- coding: utf-8 -*- - -import inspect -import importlib -import pkgutil - - -def iter_namespace(pkg): - - return pkgutil.iter_modules(pkg.__path__, pkg.__name__ + ".") - - -def get_modules(pkg): - # Return all modules in a given package - return [importlib.import_module(name) for finder, name, ispkg in iter_namespace(pkg)] - - -def get_classes(module): - # Return all classes in a given module - return inspect.getmembers(module, inspect.isclass) - - -def get_plugins(pkg, baseclass): - """ - Return a list of all modules under a given package. - - - Modules must be a subclass of the provided 'baseclass' - - Modules must have a non-empty PLUGIN_NAME parameter - """ - - plugins = [] - - modules = get_modules(pkg) - - # Iterate through each module in the package - for mod in modules: - # Iterate through each class in the module - for item in get_classes(mod): - plugin = item[1] - if issubclass(plugin, baseclass) and plugin.PLUGIN_NAME: - plugins.append(plugin) - - return plugins