mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-06 10:59:59 +00:00
21 lines
623 B
Python
21 lines
623 B
Python
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
|
|
def log_path(logs_dir: Path, deploy_type: str, distro: str, suffix: str) -> Path:
|
|
return logs_dir / f"deploy-{deploy_type}-{distro}-{suffix}.log"
|
|
|
|
|
|
def write_text(path: Path, text: str) -> None:
|
|
path.parent.mkdir(parents=True, exist_ok=True)
|
|
path.write_text(text, encoding="utf-8")
|
|
|
|
|
|
def append_text(path: Path, text: str) -> None:
|
|
path.parent.mkdir(parents=True, exist_ok=True)
|
|
existing = ""
|
|
if path.exists():
|
|
existing = path.read_text(encoding="utf-8", errors="replace")
|
|
path.write_text(existing + text, encoding="utf-8")
|