-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
44 lines (32 loc) · 1.3 KB
/
Copy pathutils.py
File metadata and controls
44 lines (32 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
"""General-purpose helper functions shared across DevCheck modules."""
import platform
from datetime import datetime, timezone
from pathlib import Path
def get_project_root() -> Path:
"""Return the absolute path to the DevCheck project directory."""
return Path(__file__).resolve().parent
def get_os_name() -> str:
"""Return a human-friendly operating system name.
Falls back to whatever platform.system() reports if the OS is not one of
the three explicitly supported platforms, so the app never crashes on an
unrecognized operating system.
"""
system = platform.system()
if system == "Darwin":
return "macOS"
if system == "Windows":
return "Windows"
if system == "Linux":
return "Linux"
return system or "Unknown"
def get_timestamp() -> str:
"""Return the current UTC time as an ISO-8601 style string."""
return datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
def ensure_directory(path: Path) -> None:
"""Create a directory (and any missing parents) if it does not already exist."""
path.mkdir(parents=True, exist_ok=True)
def print_header(title: str, width: int = 32) -> None:
"""Print a simple two-line ASCII header used throughout the CLI."""
print("=" * width)
print(title)
print("=" * len(title))