diff --git a/.config/dictionary.txt b/.config/dictionary.txt index e822547..0b8a05a 100644 --- a/.config/dictionary.txt +++ b/.config/dictionary.txt @@ -1 +1,7 @@ +bindep +bthornto +fileh +levelname +levelno pipc +uninstallation diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 79c4a33..6f69b20 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -78,6 +78,7 @@ repos: additional_dependencies: - pytest - tox + - pyyaml - repo: https://github.com/pre-commit/mirrors-mypy.git rev: v1.5.0 diff --git a/README.md b/README.md index 314be84..8131221 100644 --- a/README.md +++ b/README.md @@ -9,14 +9,15 @@ A pip-like install for ansible collections. - Install all collection python requirements - Install all collection test requirements - Checks for missing system packages -- Symlinks the current collection into the current python intepreter's site-packages -- Install all collection collection dependencies into the current python intepreter's site-packages +- Symlinks the current collection into the current python interpreter's site-packages +- Install all collection collection dependencies into the current python interpreter's site-packages By placing collections into the python site-packages directory they are discoverable by ansible as well as python and pytest. ## Usage ### Setting up a development environment + ``` $ git clone $ cd collection_repo @@ -35,6 +36,7 @@ INFO Symlinking /home/bthornto/github/ansible.scm/venv/lib64/python3.11/site ``` ### Tearing down the development environment + ``` $ pipc uninstall ansible.scm INFO Found collection name: ansible.scm from /home/bthornto/github/ansible.scm/galaxy.yml. @@ -82,7 +84,8 @@ Usage: pipc install -e .[test] python -m pipc install ansible.utils ``` -``` + +```` $ pipc uninstall --help usage: pipc uninstall [-h] collection_specifier @@ -96,4 +99,5 @@ Usage: pipc install . pipc install -e . pipc install -e .[test] - python -m pipc install ansible.utils``` \ No newline at end of file + python -m pipc install ansible.utils``` +```` diff --git a/src/pipc/constants.py b/src/pipc/constants.py index 68b5e4f..814fcae 100644 --- a/src/pipc/constants.py +++ b/src/pipc/constants.py @@ -7,5 +7,5 @@ class Constants: """Constants, for now, for pipc.""" TEST_REQUIREMENTS_PY = Path("./test-requirements.txt").resolve() - REQUIMENTS_PY = Path("./requirements.txt").resolve() + REQUIREMENTS_PY = Path("./requirements.txt").resolve() COLLECTION_BUILD_DIR = Path("./build").resolve() diff --git a/src/pipc/installer.py b/src/pipc/installer.py index 1992137..742935d 100644 --- a/src/pipc/installer.py +++ b/src/pipc/installer.py @@ -29,14 +29,14 @@ def __init__(self: Installer, app: App) -> None: """Initialize the installer. Arguments: - args: The CLI arguments + app: The app instance """ self.app: App = app def run(self: Installer) -> None: """Run the installer.""" if self.app.args.collection_specifier.startswith("."): - self._pip_install(C.REQUIMENTS_PY) + self._pip_install(C.REQUIREMENTS_PY) if "[test]" in self.app.args.collection_specifier: self._pip_install(C.TEST_REQUIREMENTS_PY) site_pkg_path = self._install_collection() diff --git a/src/pipc/logger.py b/src/pipc/logger.py index 6ce3ecc..7439b15 100644 --- a/src/pipc/logger.py +++ b/src/pipc/logger.py @@ -1,4 +1,4 @@ -"""Produce coloroed logs.""" +"""Produce pretty logs.""" from __future__ import annotations @@ -59,6 +59,9 @@ def emit(self: ExitOnExceptionHandler, record: logging.LogRecord) -> None: Args: record: The log record + + Raises: + SystemExit: If the log record is an error or critical """ super().emit(record) if record.levelno in (logging.ERROR, logging.CRITICAL): diff --git a/src/pipc/uninstaller.py b/src/pipc/uninstaller.py index b828639..90193ed 100644 --- a/src/pipc/uninstaller.py +++ b/src/pipc/uninstaller.py @@ -28,7 +28,7 @@ def __init__(self: UnInstaller, app: App) -> None: """Initialize the uninstaller. Arguments: - args: The CLI arguments + app: The app instance """ self.app: App = app @@ -42,7 +42,7 @@ def run(self: UnInstaller) -> None: logger.critical(err) return - self._pip_uninstall(C.REQUIMENTS_PY) + self._pip_uninstall(C.REQUIREMENTS_PY) self._pip_uninstall(C.TEST_REQUIREMENTS_PY) self._remove_collections() diff --git a/src/pipc/utils.py b/src/pipc/utils.py index c274331..b5e15a6 100644 --- a/src/pipc/utils.py +++ b/src/pipc/utils.py @@ -13,10 +13,13 @@ def get_galaxy() -> tuple[str, dict[str, str]]: - """Retreive the collection name from the galaxy.yml file. + """Retrieve the collection name from the galaxy.yml file. Returns: str: The collection name and dependencies + + Raises: + SystemExit: If the collection name is not found """ file_name = Path("galaxy.yml").resolve() if not file_name.exists(): @@ -39,4 +42,4 @@ def get_galaxy() -> tuple[str, dict[str, str]]: except KeyError as exc: err = f"Failed to find collection name in {file_name}: {exc}" logger.critical(err) - raise SystemExit(1) # We shouln't be here + raise SystemExit(1) # We shouldn't be here