From fe63881371036fc6d55e6a113cb3ed5029b31d2d Mon Sep 17 00:00:00 2001 From: Johannes Koester Date: Mon, 13 Nov 2023 16:29:56 +0000 Subject: [PATCH] fix: fix path handling when detective profiles --- snakemake/cli.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/snakemake/cli.py b/snakemake/cli.py index 4f8aa8749..1fbf81d25 100644 --- a/snakemake/cli.py +++ b/snakemake/cli.py @@ -268,17 +268,18 @@ def get_config_min_major(filename): else: search_dirs = [os.getcwd(), dirs.user_config_dir, dirs.site_config_dir] for d in search_dirs: - d = Path(d) - files = os.listdir(d / profile) - curr_major = int(__version__.split(".")[0]) - config_files = { - f: min_major - for f, min_major in zip(files, map(get_config_min_major, files)) - if min_major is not None and curr_major >= min_major - } - if config_files: - config_file = max(config_files, key=config_files.get) - return d / profile, d / profile / config_file + profile_candidate = Path(d) / profile + if profile_candidate.exists(): + files = os.listdir(profile_candidate) + curr_major = int(__version__.split(".")[0]) + config_files = { + f: min_major + for f, min_major in zip(files, map(get_config_min_major, files)) + if min_major is not None and curr_major >= min_major + } + if config_files: + config_file = max(config_files, key=config_files.get) + return profile_candidate, profile_candidate / config_file def get_profile_file(profile_dir: Path, file, return_default=False):