Compare commits
No commits in common. "3e85c6e42182cba29f1fc31b3dad18a1f669a756" and "86d3615928b3f71ca99d84645cc224ae84df69e5" have entirely different histories.
3e85c6e421
...
86d3615928
5 changed files with 19 additions and 22 deletions
|
@ -2,11 +2,11 @@
|
|||
|
||||
__version__ = "0.0.1"
|
||||
|
||||
import importlib
|
||||
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
|
||||
|
@ -15,8 +15,6 @@ from spcd import cmd
|
|||
from spcd.ci import project, projects
|
||||
from spcd.util import browse, cat, split, step
|
||||
|
||||
env = importlib.import_module("env")
|
||||
|
||||
COMMANDS_PREFIX = "spcd-"
|
||||
|
||||
|
||||
|
@ -39,7 +37,7 @@ def clone_project_branch() -> None:
|
|||
project.branch,
|
||||
"--",
|
||||
project.url,
|
||||
str(project.root),
|
||||
project.root,
|
||||
)
|
||||
|
||||
|
||||
|
@ -103,8 +101,8 @@ def main(main: str) -> None:
|
|||
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:
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
import os
|
||||
from pathlib import Path
|
||||
|
||||
import env
|
||||
from rwx import ps
|
||||
|
||||
from spcd import env
|
||||
from spcd.ci import project, projects
|
||||
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:
|
||||
|
|
|
@ -41,7 +41,7 @@ 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)
|
||||
|
||||
|
|
17
spcd/util.py
17
spcd/util.py
|
@ -4,11 +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 env
|
||||
|
||||
|
||||
def add_url_path(url: str, extra_path: str) -> str:
|
||||
"""Append an extra segment to an existing URL."""
|
||||
|
@ -17,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):
|
||||
|
@ -25,19 +24,17 @@ 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:
|
||||
|
|
Loading…
Reference in a new issue