MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / lookup_cargo

Function lookup_cargo

deploy/sbom/resolve_licenses.py:237–252  ·  view source on GitHub ↗

Query crates.io for a crate's license.

(name: str, version: str)

Source from the content-addressed store, hash-verified

235
236
237def lookup_cargo(name: str, version: str) -> str | None:
238 """Query crates.io for a crate's license."""
239 data = _get_json(f"https://crates.io/api/v1/crates/{name}/{version}", "crates.io")
240 if data and "version" in data:
241 return data["version"].get("license")
242 # fallback: try crate-level
243 data = _get_json(f"https://crates.io/api/v1/crates/{name}", "crates.io")
244 if data and "crate" in data:
245 versions = data.get("versions", [])
246 for v in versions:
247 if v.get("num") == version:
248 return v.get("license")
249 # last resort: latest version license
250 if versions:
251 return versions[0].get("license")
252 return None
253
254
255def lookup_npm(name: str, version: str) -> str | None:

Callers 1

resolve_componentFunction · 0.85

Calls 2

_get_jsonFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected