MCPcopy Create free account
hub / github.com/bigdra50/unity-cli / locate_hub_cli

Function locate_hub_cli

unity_cli/hub/paths.py:76–101  ·  view source on GitHub ↗

Locate Hub CLI with fallback strategy. Search order: 1. UNITY_HUB_PATH environment variable 2. PATH lookup (shutil.which) 3. Platform-specific known locations

()

Source from the content-addressed store, hash-verified

74
75@lru_cache(maxsize=1)
76def locate_hub_cli() -> Path | None:
77 """Locate Hub CLI with fallback strategy.
78
79 Search order:
80 1. UNITY_HUB_PATH environment variable
81 2. PATH lookup (shutil.which)
82 3. Platform-specific known locations
83 """
84 # 1. Environment variable override
85 if env_path := os.environ.get("UNITY_HUB_PATH"):
86 path = Path(env_path)
87 if path.exists():
88 return path
89
90 # 2. PATH lookup
91 which_names = ["unityhub", "Unity Hub"]
92 for name in which_names:
93 if which_path := shutil.which(name):
94 return Path(which_path)
95
96 # 3. Platform-specific known locations
97 for candidate in _get_platform_hub_candidates():
98 if candidate.exists():
99 return candidate
100
101 return None
102
103
104@lru_cache(maxsize=1)

Callers 2

__init__Method · 0.90
get_platform_pathsFunction · 0.85

Calls 2

getMethod · 0.45

Tested by

no test coverage detected