Skip to content

Commit

Permalink
update utils logic
Browse files Browse the repository at this point in the history
  • Loading branch information
ByteOtter committed Aug 1, 2023
1 parent 08e0ca2 commit a027bb9
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/nester/management/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@
import platform
import subprocess

import nester.exceptions as exceptions
from ..exceptions import management_excs

PACKAGE_MANAGERS: list[str] = ["zypper", "apt", "apt-get", "dnf", "packman"]


def check_pip_installed() -> bool:
"""Verify pip is installed on the current system."""

try:
subprocess.run("pip", check=True)
except subprocess.CalledProcessError:
Expand All @@ -21,7 +20,8 @@ def check_pip_installed() -> bool:


def get_package_manager() -> str | None:
"""Check what package manager is installed.
"""
Check what package manager is installed.
Attempts to identify the system Nester is installed on.
If it cannot identify the system it will raise an exception.
Expand Down Expand Up @@ -54,11 +54,13 @@ def identify_linux_package_manager() -> str | None:
try:
subprocess.run(pkgmgr)
except subprocess.CalledProcessError:
raise excpetions.UnknownDistroException(
raise management_excs.UnknownDistroException(
"Error: Distribution could not be identified."
)
return pkgmgr

return None


def check_for_virtualenv(project_name: str) -> bool:
"""
Expand All @@ -69,10 +71,11 @@ def check_for_virtualenv(project_name: str) -> bool:
:param project_name: The name of the project to check.
:return: Whether the given project has a virtualenv.
"""
pass

return False


def select_dependency_source(language: str) -> None:
def select_dependency_source(language: str) -> str:
"""
Select the source of the project's dependencies according to its language.
Expand All @@ -82,4 +85,10 @@ def select_dependency_source(language: str) -> None:
:param language: The language the project is written in.
"""
match language:
case "py":
return "pip"
case "rb":
return "gem"
# TODO
pass

0 comments on commit a027bb9

Please sign in to comment.