File size: 854 Bytes
bee9bbb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from __future__ import annotations

import json
from pathlib import Path
from typing import Any

VALID_STATUSES = {
    "direct-source-complete",
    "local-functional-complete",
    "implemented-browser-unverified",
    "evidence-incomplete",
    "deferred-enrolled-source-required",
    "out-of-scope",
}


def load_inventory(path: Path | None = None) -> dict[str, Any]:
    inventory_path = path or Path(__file__).resolve().parents[1] / "scope" / "learner-coverage.json"
    inventory = json.loads(inventory_path.read_text(encoding="utf-8"))
    for entry in inventory.get("entries", []):
        if entry.get("status") not in VALID_STATUSES:
            raise ValueError(f"unknown status: {entry.get('status')}")
    return inventory


def iter_entries(inventory: dict[str, Any]) -> tuple[dict[str, Any], ...]:
    return tuple(inventory["entries"])