| 37 | |
| 38 | |
| 39 | def read_functions(path: str) -> tuple[dict[int, tuple[str, str]], list[str]]: |
| 40 | by_id: dict[int, tuple[str, str]] = {} |
| 41 | lines = [] |
| 42 | with open(path, encoding="utf-8") as handle: |
| 43 | for line in handle: |
| 44 | line = line.rstrip("\n") |
| 45 | if not line: |
| 46 | continue |
| 47 | fields = line.split("\t") |
| 48 | if len(fields) != 3 or not fields[0].isdigit(): |
| 49 | fail(f"malformed function row in {path}: {line!r}") |
| 50 | by_id[int(fields[0])] = (fields[1], fields[2]) |
| 51 | lines.append(line) |
| 52 | return by_id, lines |
| 53 | |
| 54 | |
| 55 | def read_tests(path: str) -> list[tuple[str, str, str, str, list[int]]]: |