Compare commits

...

5 commits

Author SHA1 Message Date
3e85c6e421
mypy
Some checks failed
/ arch (push) Failing after 1m34s
/ alpine (push) Failing after 41s
/ fedora (push) Failing after 8m39s
/ debian (push) Failing after 7m48s
/ opensuse (push) Failing after 2m46s
/ alma (push) Has been cancelled
/ ubuntu (push) Has been cancelled
/ rocky (push) Has been cancelled
2024-09-14 02:44:50 +02:00
96d08df70d
env/init,cmd,util 2024-09-14 01:42:36 +02:00
051c91a195
env/main 2024-09-14 01:24:43 +02:00
6142dd763d
shadow 2024-09-14 00:35:47 +02:00
eda963ba49
mypy/project,util 2024-09-14 00:33:55 +02:00
5 changed files with 22 additions and 19 deletions

View file

@ -2,11 +2,11 @@
__version__ = "0.0.1" __version__ = "0.0.1"
import importlib
import sys import sys
from os import environ, pathsep from os import environ, pathsep
from pathlib import Path from pathlib import Path
import env
from rwx import fs from rwx import fs
from rwx.log import stream as log from rwx.log import stream as log
from rwx.ps import run from rwx.ps import run
@ -15,6 +15,8 @@ from spcd import cmd
from spcd.ci import project, projects from spcd.ci import project, projects
from spcd.util import browse, cat, split, step from spcd.util import browse, cat, split, step
env = importlib.import_module("env")
COMMANDS_PREFIX = "spcd-" COMMANDS_PREFIX = "spcd-"
@ -37,7 +39,7 @@ def clone_project_branch() -> None:
project.branch, project.branch,
"--", "--",
project.url, project.url,
project.root, str(project.root),
) )
@ -101,8 +103,8 @@ def main(main: str) -> None:
install_commands(main) install_commands(main)
install_python_packages() install_python_packages()
else: else:
function = getattr(cmd, name.replace("-", "_")) f = getattr(cmd, name.replace("-", "_"))
function(*arguments) f(*arguments)
def set_ssh() -> None: def set_ssh() -> None:

View file

@ -2,11 +2,11 @@
"""Entry point.""" """Entry point."""
import importlib
import sys import sys
import env
if __name__ == "__main__": if __name__ == "__main__":
env = importlib.import_module("env")
if env.SPCD_PYTHON_VENV_PACKAGES not in sys.path: if env.SPCD_PYTHON_VENV_PACKAGES not in sys.path:
sys.path.insert(0, env.SPCD_PYTHON_VENV_PACKAGES) sys.path.insert(0, env.SPCD_PYTHON_VENV_PACKAGES)
from spcd import main from spcd import main

View file

@ -3,9 +3,9 @@
import os import os
from pathlib import Path from pathlib import Path
import env
from rwx import ps from rwx import ps
from spcd import env
from spcd.ci import project, projects from spcd.ci import project, projects
from spcd.util import browse from spcd.util import browse
@ -18,12 +18,10 @@ def spcd_browse_workspace() -> None:
def spcd_build_project() -> None: def spcd_build_project() -> None:
"""Perform the actual building process.""" """Perform the actual building process."""
for extension in ["py", "sh"]: for extension in ["py", "sh"]:
path = Path(project.root) / f"build.{extension}" path = project.root / f"build.{extension}"
if path.exists(): if path.exists():
ps.run(path) ps.run(str(path))
break break
else:
pass
def spcd_check_project() -> None: def spcd_check_project() -> None:

View file

@ -41,7 +41,7 @@ class Project:
# root # root
for variable in ROOT: for variable in ROOT:
if value := projects.environment.get(variable, None): if value := projects.environment.get(variable, None):
self.root = value self.root = Path(value)
# url # url
self.url = add_url_path(projects.url, self.name) self.url = add_url_path(projects.url, self.name)

View file

@ -4,10 +4,11 @@ import os
from pathlib import Path from pathlib import Path
from urllib.parse import urlparse, urlunparse from urllib.parse import urlparse, urlunparse
import env
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 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."""
@ -16,7 +17,7 @@ def add_url_path(url: str, extra_path: str) -> str:
return urlunparse(parts) return urlunparse(parts)
def browse(root: str) -> 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."""
paths = [] paths = []
for directory, _, files in os.walk(root): for directory, _, files in os.walk(root):
@ -24,17 +25,19 @@ def browse(root: str) -> None:
absolute_path = Path(directory) / file absolute_path = Path(directory) / file
relative_path = os.path.relpath(absolute_path, start=root) relative_path = os.path.relpath(absolute_path, start=root)
paths.append(relative_path) paths.append(relative_path)
frame(root) text = str(root)
frame(text)
for path in sorted(paths): for path in sorted(paths):
log.info(path) log.info(path)
shut(root) shut(text)
def cat(file: str) -> 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."""
frame(file) text = str(file)
frame(text)
log.info(fs.read_file_text(file).rstrip()) log.info(fs.read_file_text(file).rstrip())
shut(file) shut(text)
def frame(text: str) -> None: def frame(text: str) -> None: