14 lines
354 B
Python
14 lines
354 B
Python
|
|
import socket
|
||
|
|
from typing import Protocol
|
||
|
|
|
||
|
|
|
||
|
|
class RepoPathLike(Protocol):
|
||
|
|
local_path: str | None
|
||
|
|
host_paths: dict
|
||
|
|
|
||
|
|
|
||
|
|
def resolve_repo_path(repo: RepoPathLike, host: str | None = None) -> str | None:
|
||
|
|
selected_host = host or socket.gethostname()
|
||
|
|
host_paths = repo.host_paths or {}
|
||
|
|
return host_paths.get(selected_host) or repo.local_path
|