util
Some checks failed
/ job (push) Failing after 14m33s

This commit is contained in:
Marc Beninca 2024-07-13 01:46:18 +02:00
parent 9c63b1e9c3
commit 678d9e0e4d
Signed by: marc.beninca
GPG key ID: 9C7613450C80C24F
3 changed files with 47 additions and 42 deletions

View file

@ -1,40 +1,20 @@
"""Python Integration, Delivery & Deployment."""
"""Shell to Python Continuous Deployment."""
__version__ = "0.0.1"
import os
import sys
from pathlib import Path
import env
from rwx import fs
from rwx.log import stream as log
import spcd
from spcd import cmd
from spcd.util import browse, cat, step
COMMANDS_PREFIX = "spcd-"
def browse(root: str) -> None:
paths = []
for directory, _, files in os.walk(root):
for file in files:
absolute_path = Path(directory) / file
relative_path = os.path.relpath(absolute_path, start=root)
paths.append(relative_path)
frame(root)
for path in sorted(paths):
log.info(path)
shut(root)
def cat(file: str) -> None:
frame(file)
log.info(fs.read_file_text(file).rstrip())
shut(file)
def install_commands(path: str) -> None:
step("Install commands")
user = Path("/usr/local/bin")
@ -85,22 +65,3 @@ def set_ssh(*arguments: list[str]) -> None:
# display
browse(ssh)
cat(known)
def frame(text: str) -> None:
log.info(f"{env.SPCD_OPEN}{text}")
def shut(text: str) -> None:
log.info(f"{env.SPCD_SHUT}{text}")
def split() -> None:
log.info(env.SPCD_SPLT)
def step(text: str) -> None:
env.SPCD_STEP += 1
log.info(env.SPCD_DOWN)
log.info(f"{env.SPCD_VERT} {env.SPCD_STEP} {text}")
log.info(env.SPCD___UP)

View file

@ -4,8 +4,8 @@ from pathlib import Path
from rwx import ps
from rwx.log import stream as log
from spcd import browse, split
from spcd.ci import project, projects
from spcd.util import browse, split
def spcd_browse_workspace() -> None:

44
spcd/util.py Normal file
View file

@ -0,0 +1,44 @@
import os
from pathlib import Path
import env
from rwx import fs
from rwx.log import stream as log
def browse(root: str) -> None:
paths = []
for directory, _, files in os.walk(root):
for file in files:
absolute_path = Path(directory) / file
relative_path = os.path.relpath(absolute_path, start=root)
paths.append(relative_path)
frame(root)
for path in sorted(paths):
log.info(path)
shut(root)
def cat(file: str) -> None:
frame(file)
log.info(fs.read_file_text(file).rstrip())
shut(file)
def frame(text: str) -> None:
log.info(f"{env.SPCD_OPEN}{text}")
def shut(text: str) -> None:
log.info(f"{env.SPCD_SHUT}{text}")
def split() -> None:
log.info(env.SPCD_SPLT)
def step(text: str) -> None:
env.SPCD_STEP += 1
log.info(env.SPCD_DOWN)
log.info(f"{env.SPCD_VERT} {env.SPCD_STEP} {text}")
log.info(env.SPCD___UP)