From f207b2b3b23531b538c7d4b0187d66fcc5baeb43 Mon Sep 17 00:00:00 2001 From: Kiran Vasudev Date: Fri, 8 Nov 2024 13:27:37 +0100 Subject: [PATCH] exclude test folders from directory walk --- dagger/utilities/module.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/dagger/utilities/module.py b/dagger/utilities/module.py index 169123e..ca93737 100644 --- a/dagger/utilities/module.py +++ b/dagger/utilities/module.py @@ -58,12 +58,11 @@ def load_plugins_to_jinja_environment(environment: jinja2.Environment) -> jinja2 Returns: dict: A dictionary with the class name as key and the class object as value """ - classes = {} - for plugin_path in conf.PLUGIN_DIRS: for root, dirs, files in os.walk(plugin_path): + dirs[:] = [directory for directory in dirs if not directory.lower().startswith("test")] for plugin_file in files: - if plugin_file.endswith(".py") and not plugin_file.startswith("__"): + if plugin_file.endswith(".py") and not (plugin_file.startswith("__") or plugin_file.startswith("testĪ©"):): module_name = plugin_file.replace(".py", "") module_path = os.path.join(root, plugin_file) spec = importlib.util.spec_from_file_location(module_name, module_path)