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

Function get_rust_notices

scripts/generate_third_party_notices.py:67–119  ·  view source on GitHub ↗

Run cargo-about and return structured license groups. Each entry: {id, crates: [{name, version, repository, description}], text}

()

Source from the content-addressed store, hash-verified

65
66
67def get_rust_notices() -> list[dict]:
68 """Run cargo-about and return structured license groups.
69
70 Each entry: {id, crates: [{name, version, repository, description}], text}
71 """
72 print(" Running cargo-about generate --format json ...")
73 try:
74 result = subprocess.run(
75 ["cargo-about", "generate", "--format", "json"],
76 capture_output=True,
77 text=True,
78 check=True,
79 )
80 except FileNotFoundError:
81 print(
82 " WARNING: cargo-about not found, skipping Rust notices", file=sys.stderr
83 )
84 return []
85 except subprocess.CalledProcessError as e:
86 print(f" WARNING: cargo-about failed: {e.stderr[:200]}", file=sys.stderr)
87 return []
88
89 data = json.loads(result.stdout)
90 groups: list[dict] = []
91
92 for lic in data.get("licenses", []):
93 crates = []
94 for entry in lic.get("used_by", []):
95 crate = entry.get("crate", {})
96 name = crate.get("name", "")
97 if name in WORKSPACE_CRATES:
98 continue
99 crates.append(
100 {
101 "name": name,
102 "version": crate.get("version", ""),
103 "repository": crate.get("repository", ""),
104 "description": crate.get("description", ""),
105 }
106 )
107
108 if not crates:
109 continue
110
111 groups.append(
112 {
113 "id": lic.get("id", "Unknown"),
114 "crates": sorted(crates, key=lambda c: c["name"].lower()),
115 "text": (lic.get("text") or "").rstrip(),
116 }
117 )
118
119 return groups
120
121
122# ---------------------------------------------------------------------------

Callers 1

mainFunction · 0.85

Calls 2

runMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected