From 4e1fea96b62905b273099e54215847b77b003942 Mon Sep 17 00:00:00 2001
From: Hans Fangohr <hans.fangohr@mpsd.mpg.de>
Date: Fri, 9 Jun 2023 07:22:54 +0200
Subject: [PATCH] remove the now unneeded 'create_dir_structure' function

- it is only called once
- easier to have the code of the function in the place where it is called now
---
 mpsd-software-environment.py | 45 ++++++++++++------------------------
 1 file changed, 15 insertions(+), 30 deletions(-)

diff --git a/mpsd-software-environment.py b/mpsd-software-environment.py
index 1b08bcf..6e0f68b 100755
--- a/mpsd-software-environment.py
+++ b/mpsd-software-environment.py
@@ -554,35 +554,6 @@ def clone_repo(
                 run(["git", "pull"], check=True)
 
 
-def create_dir_structure(mpsd_release: str, script_dir: Path) -> None:
-    """
-    Create the directory structure and clone spack environments repo.
-
-    The create_dir_structure function creates the directory structure for
-    the specified release and clones the Spack environments repository if it
-    doesn't exist.
-
-    Parameters
-    ----------
-    - mpsd_release: A string representing the MPSD release version.
-    - script_dir: A Path object representing the path to the scripts directory.
-
-    Returns
-    -------
-    - None
-    """
-    # Create the directory structure for the release
-    release_base_dir = script_dir / mpsd_release
-    release_base_dir.mkdir(parents=True, exist_ok=True)
-    repo_path = release_base_dir / "spack-environments"
-    if repo_path.exists():
-        logging.debug(f"directory {repo_path} exists already, not touching")
-    else:
-        repo_url = config_vars["spack_environments_repo"]
-        logging.info(f"cloning repository {repo_path} from {repo_url}")
-        clone_repo(repo_path, repo_url, branch=mpsd_release)
-
-
 def get_release_info(mpsd_release: str, script_dir: Path) -> Tuple[str, str, List[str]]:
     """
     Get information about the specified release.
@@ -661,7 +632,21 @@ def prepare_environment(mpsd_release: str, script_dir: Path) -> List[str]:
     available_toolchains : list
         A list of available toolchains for the given MPSD release.
     """
-    create_dir_structure(mpsd_release, script_dir)
+
+    # Creates the directory structure for the specified release and clone the
+    # Spack environments repository if it doesn't exist:
+
+    # Create the directory structure for the release
+    release_base_dir = script_dir / mpsd_release
+    release_base_dir.mkdir(parents=True, exist_ok=True)
+    repo_path = release_base_dir / "spack-environments"
+    if repo_path.exists():
+        logging.debug(f"directory {repo_path} exists already, not touching")
+    else:
+        repo_url = config_vars["spack_environments_repo"]
+        logging.info(f"cloning repository {repo_path} from {repo_url}")
+        clone_repo(repo_path, repo_url, branch=mpsd_release)
+
     spe_branch, spe_commit_hash, available_toolchains = get_release_info(
         mpsd_release, script_dir
     )
-- 
GitLab