Compare commits

..

No commits in common. "f0aa902904880dc72e52fe1d633b82940e6de1b5" and "bfc4538dcf528bc29c5144a3e480b86c2526891f" have entirely different histories.

7 changed files with 22 additions and 84 deletions

View file

@ -31,12 +31,6 @@ requires-python = ">= 3.11"
[tool.hatch.version] [tool.hatch.version]
path = "spcd/__init__.py" path = "spcd/__init__.py"
[tool.pydoclint]
allow-init-docstring = true
quiet = true
skip-checking-short-docstrings = false
style = "sphinx"
[tool.ruff] [tool.ruff]
line-length = 80 line-length = 80

View file

@ -286,7 +286,6 @@ Handle project workflows in a unified way:
* automate versions fetching * automate versions fetching
* gource, xvfb, xauth * gource, xvfb, xauth
* handle openh264 repositories * handle openh264 repositories
* link from workspace to actions root
* rpm fusion * rpm fusion
* tex * tex
* translate to french * translate to french

View file

@ -26,13 +26,10 @@ def clone_project_branch() -> None:
split() split()
log.info(project) log.info(project)
split() split()
log.info( log.info(f"""\
"""\ {project.url}
%s
""", """)
project.url,
)
run( run(
"git", "git",
"clone", "clone",
@ -69,8 +66,6 @@ def install_python_packages() -> None:
"hatch", "hatch",
"mypy", "mypy",
"pelican", "pelican",
"pydoclint",
"pylint",
"pytest", "pytest",
"ruff", "ruff",
"sphinx", "sphinx",
@ -87,12 +82,12 @@ def list_environment_variables() -> None:
step("List environment variables") step("List environment variables")
for variable, value in sorted(projects.environment.items()): for variable, value in sorted(projects.environment.items()):
if variable not in ["SPCD", "SPCD_SSH_KEY"]: if variable not in ["SPCD", "SPCD_SSH_KEY"]:
log.info("%s = %s", variable, value) log.info(f"{variable} = {value}")
else: 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.""" """Entry point to initialize environment or run a specific command."""
paths = environ["PATH"].split(pathsep) paths = environ["PATH"].split(pathsep)
if env.SPCD_PYTHON_VENV_BINARIES not in paths: if env.SPCD_PYTHON_VENV_BINARIES not in paths:
@ -103,7 +98,7 @@ def main(main_file: str) -> None:
list_environment_variables() list_environment_variables()
clone_project_branch() clone_project_branch()
set_ssh() set_ssh()
install_commands(main_file) install_commands(main)
install_python_packages() install_python_packages()
else: else:
f = getattr(cmd, name.replace("-", "_")) f = getattr(cmd, name.replace("-", "_"))

View file

@ -27,7 +27,7 @@ ROOT = [
class Project: class Project:
"""Current project.""" """Current project."""
def __init__(self, projects: Projects) -> None: def __init__(self: Project, projects: Projects) -> None:
"""Set projects, branch, name, root & url.""" """Set projects, branch, name, root & url."""
self.projects = projects self.projects = projects
# branch # branch
@ -45,11 +45,7 @@ class Project:
# url # url
self.url = add_url_path(projects.url, self.name) self.url = add_url_path(projects.url, self.name)
def __repr__(self) -> str: def __str__(self: Project) -> str:
"""Represent project."""
return f"Project(projects={self.projects!r})"
def __str__(self) -> str:
"""List branch, name, root & url.""" """List branch, name, root & url."""
return f"""\ return f"""\
branch = {self.branch} branch = {self.branch}

View file

@ -20,7 +20,7 @@ SERVER_URL = [
class Projects: class Projects:
"""Other projects.""" """Other projects."""
def __init__(self) -> None: def __init__(self: Projects) -> None:
"""Set environment, group, name & url.""" """Set environment, group, name & url."""
self.environment = os.environ self.environment = os.environ
# group, name # group, name
@ -34,20 +34,8 @@ class Projects:
if value := self.environment.get(variable, None): if value := self.environment.get(variable, None):
self.url = add_url_path(value, self.group) self.url = add_url_path(value, self.group)
def __repr__(self) -> str: def __str__(self: Projects) -> str:
"""Represent projects. """List group, name & url."""
:return: representation
:rtype: str
"""
return "Projects()"
def __str__(self) -> str:
"""List group, name & url.
:return: string
:rtype: str
"""
return f"""\ return f"""\
group = {self.group} group = {self.group}
name = {self.name} name = {self.name}

View file

@ -3,8 +3,3 @@
import importlib import importlib
env = importlib.import_module("env") env = importlib.import_module("env")
try:
STEP = int(env.SPCD_STEP)
except AttributeError:
STEP = 1

View file

@ -7,31 +7,18 @@ from urllib.parse import urlparse, urlunparse
from rwx import fs from rwx import fs
from rwx.log import stream as log from rwx.log import stream as log
from spcd import shell
from spcd.shell import env from spcd.shell import env
def add_url_path(url: str, extra_path: str) -> str: def add_url_path(url: str, extra_path: str) -> str:
"""Append an extra segment to an existing URL. """Append an extra segment to an existing URL."""
:param url: base URL
:type url: str
:param extra_path: path to append
:type extra_path: str
:return: new URL
:rtype: str
"""
parts = urlparse(url) parts = urlparse(url)
parts = parts._replace(path=str(Path(parts.path) / extra_path)) parts = parts._replace(path=str(Path(parts.path) / extra_path))
return urlunparse(parts) return urlunparse(parts)
def browse(root: Path) -> None: def browse(root: Path) -> None:
"""Frame the browsing of a root directory in the log output. """Frame the browsing of a root directory in the log output."""
:param root: directory to browse
:type root: Path
"""
paths = [] paths = []
for directory, _, files in os.walk(root): for directory, _, files in os.walk(root):
for file in files: for file in files:
@ -46,11 +33,7 @@ def browse(root: Path) -> None:
def cat(file: Path) -> None: def cat(file: Path) -> None:
"""Frame the content of a file in the log output. """Frame the content of a file in the log output."""
:param file: file to read the content from
:type file: Path
"""
text = str(file) text = str(file)
frame(text) frame(text)
log.info(fs.read_file_text(file).rstrip()) log.info(fs.read_file_text(file).rstrip())
@ -58,21 +41,13 @@ def cat(file: Path) -> None:
def frame(text: str) -> None: def frame(text: str) -> None:
"""Open a new frame in the log output. """Open a new frame in the log output."""
log.info(f"{env.SPCD_OPEN}{text}")
:param text: text to start the frame with
:type text: str
"""
log.info("%s%s", env.SPCD_OPEN, text)
def shut(text: str) -> None: def shut(text: str) -> None:
"""Close current frame in the log output. """Close current frame in the log output."""
log.info(f"{env.SPCD_SHUT}{text}")
:param text: text to shut the frame with
:type text: str
"""
log.info("%s%s", env.SPCD_SHUT, text)
def split() -> None: def split() -> None:
@ -81,12 +56,8 @@ def split() -> None:
def step(text: str) -> None: def step(text: str) -> None:
"""Increment the step number of the current build process. """Increment the step number of the current build process."""
env.SPCD_STEP += 1
:param text: text to display
:type text: str
"""
shell.STEP += 1
log.info(env.SPCD_DOWN) 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) log.info(env.SPCD___UP)