diff --git a/pyproject.toml b/pyproject.toml index 06f8b3b..3e5d6d7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,11 +31,6 @@ requires-python = ">= 3.11" [tool.hatch.version] path = "spcd/__init__.py" -[tool.pydoclint] -allow-init-docstring = true -skip-checking-short-docstrings = false -style = "sphinx" - [tool.ruff] line-length = 80 diff --git a/readme.md b/readme.md index bee7dab..df9ea36 100644 --- a/readme.md +++ b/readme.md @@ -286,7 +286,6 @@ Handle project workflows in a unified way: * automate versions fetching * gource, xvfb, xauth * handle openh264 repositories -* link from workspace to actions root * rpm fusion * tex * translate to french diff --git a/spcd/__init__.py b/spcd/__init__.py index 85fa914..0c17d01 100644 --- a/spcd/__init__.py +++ b/spcd/__init__.py @@ -6,13 +6,13 @@ import sys from os import environ, pathsep from pathlib import Path +import env from rwx import fs from rwx.log import stream as log from rwx.ps import run from spcd import cmd from spcd.ci import project, projects -from spcd.shell import env from spcd.util import browse, cat, split, step COMMANDS_PREFIX = "spcd-" @@ -26,10 +26,10 @@ def clone_project_branch() -> None: split() log.info(project) split() - log.info("""\ -%s + log.info(f"""\ +{project.url} ↓ -""", project.url) +""") run( "git", "clone", @@ -37,7 +37,7 @@ def clone_project_branch() -> None: project.branch, "--", project.url, - str(project.root), + project.root, ) @@ -66,8 +66,6 @@ def install_python_packages() -> None: "hatch", "mypy", "pelican", - "pydoclint", - "pylint", "pytest", "ruff", "sphinx", @@ -84,12 +82,12 @@ def list_environment_variables() -> None: step("List environment variables") for variable, value in sorted(projects.environment.items()): if variable not in ["SPCD", "SPCD_SSH_KEY"]: - log.info("%s = %s", variable, value) + log.info(f"{variable} = {value}") else: - log.info("%s", variable) + log.info(f"{variable}") -def main(main_file: str) -> None: +def main(main: str) -> None: """Entry point to initialize environment or run a specific command.""" paths = environ["PATH"].split(pathsep) if env.SPCD_PYTHON_VENV_BINARIES not in paths: @@ -100,11 +98,11 @@ def main(main_file: str) -> None: list_environment_variables() clone_project_branch() set_ssh() - install_commands(main_file) + install_commands(main) install_python_packages() else: - f = getattr(cmd, name.replace("-", "_")) - f(*arguments) + function = getattr(cmd, name.replace("-", "_")) + function(*arguments) def set_ssh() -> None: diff --git a/spcd/__main__.py b/spcd/__main__.py index 520540c..6aeca41 100755 --- a/spcd/__main__.py +++ b/spcd/__main__.py @@ -2,11 +2,11 @@ """Entry point.""" -import importlib import sys +import env + if __name__ == "__main__": - env = importlib.import_module("env") if env.SPCD_PYTHON_VENV_PACKAGES not in sys.path: sys.path.insert(0, env.SPCD_PYTHON_VENV_PACKAGES) from spcd import main diff --git a/spcd/cmd.py b/spcd/cmd.py index a72287b..a1108ee 100644 --- a/spcd/cmd.py +++ b/spcd/cmd.py @@ -3,10 +3,10 @@ import os from pathlib import Path +import env from rwx import ps from spcd.ci import project, projects -from spcd.shell import env from spcd.util import browse @@ -18,10 +18,12 @@ def spcd_browse_workspace() -> None: def spcd_build_project() -> None: """Perform the actual building process.""" for extension in ["py", "sh"]: - path = project.root / f"build.{extension}" + path = Path(project.root) / f"build.{extension}" if path.exists(): - ps.run(str(path)) + ps.run(path) break + else: + pass def spcd_check_project() -> None: diff --git a/spcd/project.py b/spcd/project.py index c295d57..de8b164 100644 --- a/spcd/project.py +++ b/spcd/project.py @@ -27,7 +27,7 @@ ROOT = [ class Project: """Current project.""" - def __init__(self, projects: Projects) -> None: + def __init__(self: Project, projects: Projects) -> None: """Set projects, branch, name, root & url.""" self.projects = projects # branch @@ -41,15 +41,11 @@ class Project: # root for variable in ROOT: if value := projects.environment.get(variable, None): - self.root = Path(value) + self.root = value # url self.url = add_url_path(projects.url, self.name) - def __repr__(self) -> str: - """Represent project.""" - return f"Project(projects={self.projects!r})" - - def __str__(self) -> str: + def __str__(self: Project) -> str: """List branch, name, root & url.""" return f"""\ branch = {self.branch} diff --git a/spcd/projects.py b/spcd/projects.py index 5185feb..c1f2403 100644 --- a/spcd/projects.py +++ b/spcd/projects.py @@ -20,7 +20,7 @@ SERVER_URL = [ class Projects: """Other projects.""" - def __init__(self) -> None: + def __init__(self: Projects) -> None: """Set environment, group, name & url.""" self.environment = os.environ # group, name @@ -34,11 +34,7 @@ class Projects: if value := self.environment.get(variable, None): self.url = add_url_path(value, self.group) - def __repr__(self) -> str: - """Represent projects.""" - return "Projects()" - - def __str__(self) -> str: + def __str__(self: Projects) -> str: """List group, name & url.""" return f"""\ group = {self.group} diff --git a/spcd/shell.py b/spcd/shell.py deleted file mode 100644 index 0a587e7..0000000 --- a/spcd/shell.py +++ /dev/null @@ -1,10 +0,0 @@ -"""Shell for environment module.""" - -import importlib - -env = importlib.import_module("env") - -try: - STEP = int(env.SPCD_STEP) -except AttributeError: - STEP = 1 diff --git a/spcd/util.py b/spcd/util.py index 66fd269..9ea9dca 100644 --- a/spcd/util.py +++ b/spcd/util.py @@ -4,12 +4,10 @@ import os from pathlib import Path from urllib.parse import urlparse, urlunparse +import env from rwx import fs from rwx.log import stream as log -from spcd import shell -from spcd.shell import env - def add_url_path(url: str, extra_path: str) -> str: """Append an extra segment to an existing URL.""" @@ -18,7 +16,7 @@ def add_url_path(url: str, extra_path: str) -> str: return urlunparse(parts) -def browse(root: Path) -> None: +def browse(root: str) -> None: """Frame the browsing of a root directory in the log output.""" paths = [] for directory, _, files in os.walk(root): @@ -26,29 +24,27 @@ def browse(root: Path) -> None: absolute_path = Path(directory) / file relative_path = os.path.relpath(absolute_path, start=root) paths.append(relative_path) - text = str(root) - frame(text) + frame(root) for path in sorted(paths): log.info(path) - shut(text) + shut(root) -def cat(file: Path) -> None: +def cat(file: str) -> None: """Frame the content of a file in the log output.""" - text = str(file) - frame(text) + frame(file) log.info(fs.read_file_text(file).rstrip()) - shut(text) + shut(file) def frame(text: str) -> None: """Open a new frame in the log output.""" - log.info("%s%s", env.SPCD_OPEN, text) + log.info(f"{env.SPCD_OPEN}{text}") def shut(text: str) -> None: """Close current frame in the log output.""" - log.info("%s%s", env.SPCD_SHUT, text) + log.info(f"{env.SPCD_SHUT}{text}") def split() -> None: @@ -58,7 +54,7 @@ def split() -> None: def step(text: str) -> None: """Increment the step number of the current build process.""" - shell.STEP += 1 + env.SPCD_STEP += 1 log.info(env.SPCD_DOWN) - log.info("%s %s %s", env.SPCD_VERT, shell.STEP, text) + log.info(f"{env.SPCD_VERT} {env.SPCD_STEP} {text}") log.info(env.SPCD___UP)