diff --git a/tutorpicasso/commands/enable_private_packages.py b/tutorpicasso/commands/enable_private_packages.py index 8ffdc68..c02dbf5 100644 --- a/tutorpicasso/commands/enable_private_packages.py +++ b/tutorpicasso/commands/enable_private_packages.py @@ -17,7 +17,7 @@ def enable_private_packages() -> None: defining them as private. Raises: - Exception: If an error occurs during the cloning or defining process. + Exception: If there is not enough information to clone the repo. """ context = click.get_current_context().obj tutor_root = context.root @@ -41,39 +41,33 @@ def enable_private_packages() -> None: file.write("") for package, info in packages.items(): - try: - if not {"name", "repo", "version"}.issubset(info): - raise KeyError( - f"{package} is missing one of the required keys: 'name', 'repo', 'version'" - ) - - if os.path.isdir(f'{private_requirements_root}/{info["name"]}'): - subprocess.call( - ["rm", "-rf", f'{private_requirements_root}/{info["name"]}'] - ) + if not {"name", "repo", "version"}.issubset(info): + raise click.ClickException( + f"{package} is missing one of the required keys: 'name', 'repo', 'version'" + ) + if os.path.isdir(f'{private_requirements_root}/{info["name"]}'): subprocess.call( - ["git", "clone", "-b", info["version"], info["repo"]], - cwd=private_requirements_root, + ["rm", "-rf", f'{private_requirements_root}/{info["name"]}'] ) - if tutor_version_obj < quince_version_obj: - echo_command = ( - f'echo "-e ./{info["name"]}/" >> {private_requirements_txt}' - ) - subprocess.call(echo_command, shell=True) - else: - subprocess.call( - [ - "tutor", - "mounts", - "add", - f'{private_requirements_root}/{info["name"]}', - ] - ) + subprocess.call( + ["git", "clone", "-b", info["version"], info["repo"]], + cwd=private_requirements_root, + ) - except KeyError as e: - raise click.ClickException(str(e)) + if tutor_version_obj < quince_version_obj: + echo_command = f'echo "-e ./{info["name"]}/" >> {private_requirements_txt}' + subprocess.call(echo_command, shell=True) + else: + subprocess.call( + [ + "tutor", + "mounts", + "add", + f'{private_requirements_root}/{info["name"]}', + ] + ) def get_picasso_packages(settings: Dict[str, Any]) -> Dict[str, Dict[str, Any]]: