Skip to content

Commit

Permalink
refactor: improve the naming in enable_private_packages
Browse files Browse the repository at this point in the history
  • Loading branch information
MaferMazu committed Aug 26, 2024
1 parent c8eefa0 commit 9cf3ec5
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions tutorpicasso/commands/enable_private_packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,29 @@ def enable_private_packages() -> None:
tutor_root = context.root
tutor_conf = tutor_config.load(tutor_root)

private_requirements_root = f"{tutor_root}/env/build/openedx/private_requirements"
private_requirements_path = f"{tutor_root}/env/build/openedx/requirements"
packages = get_picasso_packages(tutor_conf)

if not os.path.exists(private_requirements_root):
os.makedirs(private_requirements_root)
if not os.path.exists(private_requirements_path):
os.makedirs(private_requirements_path)

for package, info in packages.items():
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"]}'):
if os.path.isdir(f'{private_requirements_path}/{info["name"]}'):
subprocess.call(
["rm", "-rf", f'{private_requirements_root}/{info["name"]}']
["rm", "-rf", f'{private_requirements_path}/{info["name"]}']
)

subprocess.call(
["git", "clone", "-b", info["version"], info["repo"]],
cwd=private_requirements_root,
cwd=private_requirements_path,
)

handle_private_requirements_by_tutor_version(info, private_requirements_root)
handle_private_requirements_by_tutor_version(info, private_requirements_path)


def handle_private_requirements_by_tutor_version(info: Dict[str, str], private_requirements_path: str) -> None:
Expand All @@ -61,12 +61,12 @@ def handle_private_requirements_by_tutor_version(info: Dict[str, str], private_r

if tutor_version_obj < quince_version_obj:
private_txt_path = f"{private_requirements_path}/private.txt"
_enable_private_packages_before_quince(info, private_txt_path)
_enable_private_requirements_before_quince(info, private_txt_path)
else:
_enable_private_packages_latest(info, private_requirements_path)
_enable_private_requirements_latest(info, private_requirements_path)


def _enable_private_packages_before_quince(
def _enable_private_requirements_before_quince(
info: Dict[str, str], private_requirements_txt: str
) -> None:
"""
Expand All @@ -84,7 +84,7 @@ def _enable_private_packages_before_quince(
subprocess.call(echo_command, shell=True)


def _enable_private_packages_latest(
def _enable_private_requirements_latest(
info: Dict[str, str], private_requirements_root: str
) -> None:
"""
Expand Down

0 comments on commit 9cf3ec5

Please sign in to comment.