From a335212e8cd0a65f07b9deed4ea1a31ae3f35648 Mon Sep 17 00:00:00 2001 From: mirpedrol Date: Tue, 7 Jan 2025 15:01:56 +0100 Subject: [PATCH] only append module name if it is a dir and contains main.nf --- nf_core/modules/modules_utils.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/nf_core/modules/modules_utils.py b/nf_core/modules/modules_utils.py index ecfe5f24ee..0f42d1bcea 100644 --- a/nf_core/modules/modules_utils.py +++ b/nf_core/modules/modules_utils.py @@ -65,19 +65,20 @@ def get_installed_modules(directory: Path, repo_type="modules") -> Tuple[List[st local_modules = sorted([x for x in local_modules if x.endswith(".nf")]) # Get nf-core modules - if os.path.exists(nfcore_modules_dir): - for m in sorted([m for m in os.listdir(nfcore_modules_dir) if not m == "lib"]): - if not os.path.isdir(os.path.join(nfcore_modules_dir, m)): + if nfcore_modules_dir.exists(): + for m in sorted([m for m in nfcore_modules_dir.iterdir() if not m == "lib"]): + if not m.is_dir(): raise ModuleExceptionError( f"File found in '{nfcore_modules_dir}': '{m}'! This directory should only contain module directories." ) - m_content = os.listdir(os.path.join(nfcore_modules_dir, m)) + m_content = [d.name for d in m.iterdir()] # Not a module, but contains sub-modules if "main.nf" not in m_content: for tool in m_content: - nfcore_modules_names.append(os.path.join(m, tool)) + if (m / tool).is_dir() and "main.nf" in [d.name for d in (m / tool).iterdir()]: + nfcore_modules_names.append(str(Path(m.name, tool))) else: - nfcore_modules_names.append(m) + nfcore_modules_names.append(m.name) # Make full (relative) file paths and create NFCoreComponent objects if local_modules_dir: