(path: Path)
| 187 | |
| 188 | |
| 189 | def _parse_sha256_file(path: Path) -> dict[str, str]: |
| 190 | checksums: dict[str, str] = {} |
| 191 | for line_number, line in enumerate( |
| 192 | path.read_text(encoding="utf-8").splitlines(), 1 |
| 193 | ): |
| 194 | line = line.strip() |
| 195 | if not line: |
| 196 | continue |
| 197 | |
| 198 | parts = line.split() |
| 199 | if len(parts) < 2: |
| 200 | raise ValueError(f"{path}:{line_number}: malformed checksum line") |
| 201 | |
| 202 | digest = parts[0].lower() |
| 203 | if not _SHA256_RE.fullmatch(digest): |
| 204 | raise ValueError(f"{path}:{line_number}: invalid SHA-256 digest") |
| 205 | |
| 206 | filename = parts[1].lstrip("*") |
| 207 | checksums[filename] = digest |
| 208 | |
| 209 | return checksums |
| 210 | |
| 211 | |
| 212 | def _required_checksum( |
no outgoing calls
no test coverage detected