MCPcopy Index your code
hub / github.com/github/copilot-sdk / _extract_zip

Function _extract_zip

python/copilot/_cli_download.py:185–204  ·  view source on GitHub ↗

Extract the CLI binary from a .zip archive.

(data: bytes, binary_name: str, dest_dir: Path)

Source from the content-addressed store, hash-verified

183
184
185def _extract_zip(data: bytes, binary_name: str, dest_dir: Path) -> Path:
186 """Extract the CLI binary from a .zip archive."""
187 with zipfile.ZipFile(io.BytesIO(data)) as zf:
188 names = zf.namelist()
189 target_member = None
190 for name in names:
191 if name == binary_name or name.endswith(f"/{binary_name}"):
192 target_member = name
193 break
194
195 if target_member is None:
196 raise RuntimeError(
197 f"Binary '{binary_name}' not found in archive. Archive contains: {names}"
198 )
199
200 dest_path = dest_dir / binary_name
201 with zf.open(target_member) as src, open(dest_path, "wb") as out:
202 out.write(src.read())
203
204 return dest_path
205
206
207def download_cli(version: str | None = None, *, force: bool = False) -> str:

Callers 1

download_cliFunction · 0.85

Calls 3

openMethod · 0.65
writeMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…