mypy/project,util

This commit is contained in:
Marc Beninca 2024-09-14 00:33:55 +02:00
parent 86d3615928
commit eda963ba49
Signed by: marc.beninca
GPG key ID: 9C7613450C80C24F
2 changed files with 9 additions and 7 deletions

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

@ -16,7 +16,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 +24,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: