From 97e59752974e50687d0c17d15274705811c86d5c Mon Sep 17 00:00:00 2001 From: Reid 'arrdem' McKenzie Date: Mon, 17 Oct 2022 11:13:12 -0600 Subject: [PATCH] Fix names of standalone pkgs --- src/python/cram/__main__.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/python/cram/__main__.py b/src/python/cram/__main__.py index dc9b95d..a583c98 100644 --- a/src/python/cram/__main__.py +++ b/src/python/cram/__main__.py @@ -119,13 +119,19 @@ def load_profile(root, name): def load_packages(root: Path, roots) -> dict: """Load the configured packages.""" + def _load_package(p): + name = str(p.relative_to(root)).replace(".toml", "") + try: + packages[name] = load_package(p, name) + except Exception as e: + log.exception(f"Unable to load {p} due to exception") + packages = {} for r in roots.get("package", []): r = root / expandvars(r) log.debug(f"Trying to load packages from {r}...") for p in r.glob("*"): - name = str(p.relative_to(root)) - packages[name] = load_package(p, name) + _load_package(p) for r in roots.get("profile", []): # Add profiles, hosts which contain subpackages. @@ -133,11 +139,10 @@ def load_packages(root: Path, roots) -> dict: log.debug(f"Trying to load profiles from {r}...") for mp_root in r.glob("*"): # First find all subpackages - log.debug(f"Trying to load packages from {mp_root}...") + log.debug(f"Trying to load subpackages from {mp_root}...") for p in mp_root.glob("*"): - if p.is_dir(): - name = str(p.relative_to(root)) - packages[name] = load_package(p, name) + if (p.is_dir() or (p.is_file() and p.suffix in ['.toml'])): + _load_package(p) # Register the metapackages themselves using the profile type mp_name = str(mp_root.relative_to(root))