diff --git a/doxy/__init__.py b/doxy/__init__.py index b794fd4..3dc1f76 100644 --- a/doxy/__init__.py +++ b/doxy/__init__.py @@ -1 +1 @@ -__version__ = '0.1.0' +__version__ = "0.1.0" diff --git a/doxy/cli.py b/doxy/cli.py index f2a51e2..9873a13 100644 --- a/doxy/cli.py +++ b/doxy/cli.py @@ -1,11 +1,11 @@ -import click from pathlib import Path +import click from rich import print from rich.tree import Tree -from doxy.config import Config from doxy import services +from doxy.config import Config @click.group() @@ -29,14 +29,20 @@ def list(ctx): def complete_service_name(ctx, param, incomplete): config = Config() config.load() - return [k for k in services.find_services(Path(config.root_directory)) if k.startswith(incomplete)] + return [ + k + for k in services.find_services(Path(config.root_directory)) + if k.startswith(incomplete) + ] @click.command() @click.argument("service", nargs=1, shell_complete=complete_service_name) @click.pass_context def edit(ctx, service): - compose_file = services.get_compose_file(Path(ctx.obj["CONFIG"].root_directory) / service) + compose_file = services.get_compose_file( + Path(ctx.obj["CONFIG"].root_directory) / service + ) click.edit(filename=Path(compose_file)) @@ -45,7 +51,9 @@ def edit(ctx, service): @click.argument("service", nargs=1, shell_complete=complete_service_name) @click.argument("command", nargs=-1) def control(ctx, service, command): - compose_file = services.get_compose_file(Path(ctx.obj["CONFIG"].root_directory) / service) + compose_file = services.get_compose_file( + Path(ctx.obj["CONFIG"].root_directory) / service + ) services.docker_compose_command(command, compose_file) diff --git a/doxy/config.py b/doxy/config.py index 01fc2b6..c606b83 100644 --- a/doxy/config.py +++ b/doxy/config.py @@ -1,14 +1,16 @@ -from xdg import xdg_config_home -from pathlib import Path from dataclasses import dataclass +from pathlib import Path +from xdg import xdg_config_home from yamldataclassconfig import create_file_path_field from yamldataclassconfig.config import YamlDataClassConfig @dataclass class Config(YamlDataClassConfig): - root_directory: str = None - compose_executable: str = None + root_directory: str = "" + compose_executable: str = "" - FILE_PATH: Path = create_file_path_field(Path(xdg_config_home()) / "doxy/config.yml") + FILE_PATH: Path = create_file_path_field( + Path(xdg_config_home()) / "doxy/config.yml" + ) diff --git a/doxy/services.py b/doxy/services.py index 1f757a2..bed762e 100644 --- a/doxy/services.py +++ b/doxy/services.py @@ -1,7 +1,7 @@ import glob -from typing import List -from pathlib import Path import subprocess +from pathlib import Path +from typing import List import click @@ -18,7 +18,7 @@ def get_compose_file(service_path: Path) -> Path: raise FileNotFoundError -def docker_compose_command(commands: List[str], compose_file: Path): +def docker_compose_command(commands: List[str], compose_file: Path): ctx = click.get_current_context() config = ctx.obj["CONFIG"] cmd = [config.compose_executable, "-f", compose_file] + list(commands) diff --git a/poetry.lock b/poetry.lock index a06cbf0..f0562ea 100644 --- a/poetry.lock +++ b/poetry.lock @@ -22,6 +22,14 @@ tests = ["attrs", "zope.interface"] tests-no-zope = ["hypothesis", "pympler", "pytest (>=4.3.0)", "pytest-xdist", "cloudpickle", "mypy (>=0.971,<0.990)", "pytest-mypy-plugins"] tests_no_zope = ["hypothesis", "pympler", "pytest (>=4.3.0)", "pytest-xdist", "cloudpickle", "mypy (>=0.971,<0.990)", "pytest-mypy-plugins"] +[[package]] +name = "cfgv" +version = "3.3.1" +description = "Validate configuration and produce human readable error messages." +category = "dev" +optional = false +python-versions = ">=3.6.1" + [[package]] name = "click" version = "8.1.3" @@ -68,6 +76,37 @@ typing-inspect = ">=0.4.0" [package.extras] dev = ["pytest (>=6.2.3)", "ipython", "mypy (>=0.710)", "hypothesis", "portray", "flake8", "simplejson", "types-dataclasses"] +[[package]] +name = "distlib" +version = "0.3.6" +description = "Distribution utilities" +category = "dev" +optional = false +python-versions = "*" + +[[package]] +name = "filelock" +version = "3.9.0" +description = "A platform independent file lock." +category = "dev" +optional = false +python-versions = ">=3.7" + +[package.extras] +docs = ["furo (>=2022.12.7)", "sphinx-autodoc-typehints (>=1.19.5)", "sphinx (>=5.3)"] +testing = ["covdefaults (>=2.2.2)", "coverage (>=7.0.1)", "pytest-cov (>=4)", "pytest-timeout (>=2.1)", "pytest (>=7.2)"] + +[[package]] +name = "identify" +version = "2.5.12" +description = "File identification library for Python" +category = "dev" +optional = false +python-versions = ">=3.7" + +[package.extras] +license = ["ukkonen"] + [[package]] name = "marshmallow" version = "3.19.0" @@ -112,6 +151,14 @@ category = "main" optional = false python-versions = "*" +[[package]] +name = "nodeenv" +version = "1.7.0" +description = "Node.js virtual environment builder" +category = "dev" +optional = false +python-versions = ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*" + [[package]] name = "packaging" version = "23.0" @@ -120,6 +167,18 @@ category = "main" optional = false python-versions = ">=3.7" +[[package]] +name = "platformdirs" +version = "2.6.2" +description = "A small Python package for determining appropriate platform-specific dirs, e.g. a \"user data dir\"." +category = "dev" +optional = false +python-versions = ">=3.7" + +[package.extras] +docs = ["furo (>=2022.12.7)", "proselint (>=0.13)", "sphinx-autodoc-typehints (>=1.19.5)", "sphinx (>=5.3)"] +test = ["appdirs (==1.4.4)", "covdefaults (>=2.2.2)", "pytest-cov (>=4)", "pytest-mock (>=3.10)", "pytest (>=7.2)"] + [[package]] name = "pluggy" version = "0.13.1" @@ -131,6 +190,21 @@ python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" [package.extras] dev = ["pre-commit", "tox"] +[[package]] +name = "pre-commit" +version = "2.21.0" +description = "A framework for managing and maintaining multi-language pre-commit hooks." +category = "dev" +optional = false +python-versions = ">=3.7" + +[package.dependencies] +cfgv = ">=2.0.0" +identify = ">=1.0.0" +nodeenv = ">=0.11.1" +pyyaml = ">=5.1" +virtualenv = ">=20.10.0" + [[package]] name = "py" version = "1.11.0" @@ -215,6 +289,23 @@ python-versions = "*" mypy-extensions = ">=0.3.0" typing-extensions = ">=3.7.4" +[[package]] +name = "virtualenv" +version = "20.17.1" +description = "Virtual Python Environment builder" +category = "dev" +optional = false +python-versions = ">=3.6" + +[package.dependencies] +distlib = ">=0.3.6,<1" +filelock = ">=3.4.1,<4" +platformdirs = ">=2.4,<3" + +[package.extras] +docs = ["proselint (>=0.13)", "sphinx (>=5.3)", "sphinx-argparse (>=0.3.2)", "sphinx-rtd-theme (>=1)", "towncrier (>=22.8)"] +testing = ["coverage (>=6.2)", "coverage-enable-subprocess (>=1)", "flaky (>=3.7)", "packaging (>=21.3)", "pytest (>=7.0.1)", "pytest-env (>=0.6.2)", "pytest-freezegun (>=0.4.2)", "pytest-mock (>=3.6.1)", "pytest-randomly (>=3.10.3)", "pytest-timeout (>=2.1)"] + [[package]] name = "wcwidth" version = "0.2.5" @@ -246,11 +337,15 @@ pyyaml = "*" [metadata] lock-version = "1.1" python-versions = "^3.10" -content-hash = "72942f32380106b34c1f20b641d7483fe6a897edb751978223a6c971b6b5bb27" +content-hash = "170eebbe419588237954ba9ca730e93d253a3c4baba92e4a26a88eff89fce121" [metadata.files] atomicwrites = [] attrs = [] +cfgv = [ + {file = "cfgv-3.3.1-py2.py3-none-any.whl", hash = "sha256:c6a0883f3917a037485059700b9e75da2464e6c27051014ad85ba6aaa5884426"}, + {file = "cfgv-3.3.1.tar.gz", hash = "sha256:f5a830efb9ce7a445376bb66ec94c638a9787422f96264c98edc6bdeed8ab736"}, +] click = [ {file = "click-8.1.3-py3-none-any.whl", hash = "sha256:bb4d8133cb15a609f44e8213d9b391b0809795062913b383c62be0ee95b1db48"}, {file = "click-8.1.3.tar.gz", hash = "sha256:7682dc8afb30297001674575ea00d1814d808d6a36af415a82bd481d37ba7b8e"}, @@ -261,6 +356,9 @@ commonmark = [ {file = "commonmark-0.9.1.tar.gz", hash = "sha256:452f9dc859be7f06631ddcb328b6919c67984aca654e5fefb3914d54691aed60"}, ] dataclasses-json = [] +distlib = [] +filelock = [] +identify = [] marshmallow = [] marshmallow-enum = [] more-itertools = [] @@ -268,8 +366,11 @@ mypy-extensions = [ {file = "mypy_extensions-0.4.3-py2.py3-none-any.whl", hash = "sha256:090fedd75945a69ae91ce1303b5824f428daf5a028d2f6ab8a299250a846f15d"}, {file = "mypy_extensions-0.4.3.tar.gz", hash = "sha256:2d82818f5bb3e369420cb3c4060a7970edba416647068eb4c5343488a6c604a8"}, ] +nodeenv = [] packaging = [] +platformdirs = [] pluggy = [] +pre-commit = [] py = [ {file = "py-1.11.0-py2.py3-none-any.whl", hash = "sha256:607c53218732647dff4acdfcd50cb62615cedf612e72d1724fb1a0cc6405b378"}, {file = "py-1.11.0.tar.gz", hash = "sha256:51c75c4126074b472f746a24399ad32f6053d1b34b68d2fa41e558e6f4a98719"}, @@ -314,6 +415,7 @@ pyyaml = [ rich = [] typing-extensions = [] typing-inspect = [] +virtualenv = [] wcwidth = [] xdg = [] yamldataclassconfig = [] diff --git a/pyproject.toml b/pyproject.toml index 99233c6..93d16a7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "doxy" -version = "0.2.0" +version = "0.3.0" description = "" authors = ["jpk "] @@ -16,6 +16,7 @@ doxy = "doxy.cli:main" [tool.poetry.dev-dependencies] pytest = "^5.2" +pre-commit = "^2.21.0" [build-system] requires = ["poetry-core>=1.0.0"] diff --git a/tests/test_doxy.py b/tests/test_doxy.py index 73c5b46..b6942c9 100644 --- a/tests/test_doxy.py +++ b/tests/test_doxy.py @@ -2,4 +2,4 @@ from doxy import __version__ def test_version(): - assert __version__ == '0.1.0' + assert __version__ == "0.1.0"