(gamedb)
| 13 | |
| 14 | |
| 15 | def collect_expected_codes(gamedb): |
| 16 | by_prefix = defaultdict(set) |
| 17 | for game in gamedb: |
| 18 | for code in game.get('codes', []): |
| 19 | if not code: |
| 20 | continue |
| 21 | code = code.strip() |
| 22 | m = re.match(r'^([A-Za-z0-9]+)-', code) |
| 23 | if m: |
| 24 | prefix = m.group(1).upper() |
| 25 | else: |
| 26 | prefix = code.upper() |
| 27 | by_prefix[prefix].add(code.upper()) |
| 28 | return by_prefix |
| 29 | |
| 30 | |
| 31 | def load_cover_names(covers_dir: Path): |