Compare commits

...

18 commits

Author SHA1 Message Date
f0aa902904
doc/projects
Some checks failed
/ arch (push) Successful in 1m39s
/ alpine (push) Successful in 42s
/ fedora (push) Successful in 11m26s
/ opensuse (push) Successful in 2m19s
/ alma (push) Successful in 2m31s
/ rocky (push) Successful in 3m57s
/ ubuntu (push) Successful in 1m26s
/ debian (push) Failing after 1m3s
2024-09-16 01:40:27 +02:00
0d1ad96295
doc/quiet 2024-09-16 01:18:03 +02:00
ac72fb1331
doc/add_url_path 2024-09-16 01:14:52 +02:00
7251ca35fa
format 2024-09-16 01:13:18 +02:00
40bb13c39a
doc/browse,cat 2024-09-16 01:08:25 +02:00
ba8c9baa54
doc/frame,shut,step 2024-09-16 01:03:41 +02:00
ae015fdfc4
tasks/link
Some checks failed
/ arch (push) Failing after 14s
/ alpine (push) Failing after 11s
/ fedora (push) Failing after 13s
/ opensuse (push) Failing after 10s
/ alma (push) Failing after 11s
/ rocky (push) Failing after 10s
/ ubuntu (push) Failing after 10s
/ debian (push) Failing after 12s
2024-09-15 22:44:49 +02:00
69b06db6ad
pydoclint 2024-09-15 15:04:52 +02:00
b112043e10
pyproject/pydoclint 2024-09-15 15:03:31 +02:00
725bf8b981
projects/repr 2024-09-15 01:19:51 +02:00
d3d09445a0
project/repr 2024-09-15 01:14:39 +02:00
e0da3ad50c
%s 2024-09-15 01:00:17 +02:00
844543f755
×4 cyclic 2024-09-15 00:43:23 +02:00
10941ad0d8
step/upper 2024-09-15 00:09:47 +02:00
201ba91e00
rename 2024-09-15 00:03:48 +02:00
c7cb8316e9
pylint 2024-09-14 21:48:38 +02:00
400fefeecc
self/:useless 2024-09-14 15:55:12 +02:00
4bd86a8880
shell/step 2024-09-14 11:36:14 +02:00
7 changed files with 84 additions and 22 deletions

View file

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

View file

@ -286,6 +286,7 @@ 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

View file

@ -26,10 +26,13 @@ def clone_project_branch() -> None:
split()
log.info(project)
split()
log.info(f"""\
{project.url}
log.info(
"""\
%s
""")
""",
project.url,
)
run(
"git",
"clone",
@ -66,6 +69,8 @@ def install_python_packages() -> None:
"hatch",
"mypy",
"pelican",
"pydoclint",
"pylint",
"pytest",
"ruff",
"sphinx",
@ -82,12 +87,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(f"{variable} = {value}")
log.info("%s = %s", variable, value)
else:
log.info(f"{variable}")
log.info("%s", variable)
def main(main: str) -> None:
def main(main_file: 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:
@ -98,7 +103,7 @@ def main(main: str) -> None:
list_environment_variables()
clone_project_branch()
set_ssh()
install_commands(main)
install_commands(main_file)
install_python_packages()
else:
f = getattr(cmd, name.replace("-", "_"))

View file

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

View file

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

View file

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

View file

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