refactor(util): move expand_tilde to top-level claude_bottle/util.py
test / run tests/run_tests.py (pull_request) Successful in 21s

_expand_tilde was a path-string helper on DockerBottleBackend but
nothing about it was Docker-specific — any future backend reading
host paths from manifest entries would want it. Lift to
claude_bottle/util.py (sibling of log.py / manifest.py) as a public
expand_tilde() function. Docker-specific primitives stay in
claude_bottle/backend/docker/util.py.
This commit is contained in:
2026-05-11 00:52:33 -04:00
parent 6298d33c31
commit 8457869dcd
2 changed files with 21 additions and 8 deletions
+18
View File
@@ -0,0 +1,18 @@
"""Cross-cutting utility helpers used by multiple modules.
Top-level (i.e. backend-agnostic) — Docker-specific helpers live in
claude_bottle/backend/docker/util.py."""
from __future__ import annotations
import os
def expand_tilde(path: str) -> str:
"""Expand a leading '~' to $HOME. Leaves paths without a leading
tilde unchanged. Falls back to the empty string if $HOME is unset
(callers should already have checked HOME if they care)."""
if path.startswith("~"):
home = os.environ.get("HOME", "")
return home + path[1:]
return path