(shortname, cddl_filename) for the core spec and each linked spec, resolved through webref's index.
(webref_commit, urls)
| 224 | |
| 225 | |
| 226 | def resolve_specs(webref_commit, urls): |
| 227 | """(shortname, cddl_filename) for the core spec and each linked spec, resolved through webref's index.""" |
| 228 | index = json.loads(get(WEBREF_RAW.format(commit=webref_commit, path="index.json")))["results"] |
| 229 | by_shortname = {entry["shortname"]: entry for entry in index} |
| 230 | entries = [by_shortname[CORE_SHORTNAME]] |
| 231 | for url in urls: |
| 232 | matches = [entry for entry in index if url.rstrip("/") in spec_urls(entry)] |
| 233 | if len(matches) != 1: |
| 234 | raise RuntimeError(f"Expected one webref spec for {url}, found {len(matches)}") |
| 235 | entries.append(matches[0]) |
| 236 | |
| 237 | specs = [] |
| 238 | for entry in entries: |
| 239 | extracts = [extract["file"] for extract in entry.get("cddl", []) if extract["name"] == "all"] |
| 240 | if len(extracts) != 1: |
| 241 | raise RuntimeError(f"{entry['shortname']} has no single 'all' CDDL extract in webref: {entry.get('cddl')}") |
| 242 | specs.append((entry["shortname"], Path(extracts[0]).name)) |
| 243 | return specs |
| 244 | |
| 245 | |
| 246 | def repo_names(shortname): |