mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-12-02 06:18:51 -06:00
README.md and CONTRIBUTING.md open with a comment naming their generator, generate_readme.py --check fails on a hand edit in validate.yml and pr_checks.py, and .gitattributes marks the pipeline outputs as generated, held equal to core/generated.py by a test. _mame_clones.json becomes mame_clones.json, still written beside the scanned bios/ tree, and now triggers both workflows (coverage reads it). docs_assets/ moves to website/assets/, which Astro does not read as content. ACCESSIBILITY.md becomes wiki/accessibility.md, linked from the README and the installer page. The screenshot list moves to wiki/images-wanted.md: nothing read docs_assets/screens/. The architecture map names every root entry (test_repository_map), platforms/README.md keeps only what this folder holds, the reference index lists archive-recipes and measurements, and reference-terms no longer defines Profile twice nor repeats the glossary's Pack.
70 lines
2.2 KiB
Python
70 lines
2.2 KiB
Python
"""Deduplicate bios/: keep one canonical file per unique content.
|
|
|
|
Usage:
|
|
python scripts/dedup.py [--dry-run] [--bios-dir bios]
|
|
|
|
Two types of deduplication:
|
|
|
|
1. TRUE DUPLICATES: Same filename in different directories (e.g., naomi.zip
|
|
in both Arcade/ and Sega/Dreamcast/). Keeps one canonical copy, removes
|
|
the others. resolve_local_file finds files by hash, not path.
|
|
|
|
2. MAME DEVICE CLONES: Different filenames with identical content in the same
|
|
MAME directory (e.g., bbc_m87.zip and bbc_24bbc.zip are identical ZIPs).
|
|
These are NOT aliases: MAME loads each by its unique name. Instead of
|
|
deleting, we create a mame_clones.json mapping so generate_pack.py can
|
|
pack all names from a single canonical file.
|
|
|
|
After dedup, run generate_db.py --force to rebuild database indexes.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import argparse
|
|
import os
|
|
import sys
|
|
|
|
sys.path.insert(0, os.path.dirname(__file__))
|
|
from collection.dedup import deduplicate
|
|
from collection.deduptext import report_lines
|
|
from core.cli import add_repo_inputs, require_directory
|
|
from model.database import CloneMapUnreadable
|
|
|
|
|
|
def build_parser() -> argparse.ArgumentParser:
|
|
parser = argparse.ArgumentParser(allow_abbrev=False, description="Deduplicate bios/ directory")
|
|
parser.add_argument(
|
|
"--dry-run", action="store_true", help="Preview without deleting"
|
|
)
|
|
add_repo_inputs(parser, "bios")
|
|
return parser
|
|
|
|
|
|
def main() -> int:
|
|
args = build_parser().parse_args()
|
|
require_directory(args.bios_dir)
|
|
|
|
print(f"Scanning {args.bios_dir}/ for duplicates...")
|
|
if args.dry_run:
|
|
print("(DRY RUN)\n")
|
|
|
|
try:
|
|
result = deduplicate(args.bios_dir, dry_run=args.dry_run)
|
|
except CloneMapUnreadable as e:
|
|
raise SystemExit(f"{e} before deduplicating again") from e
|
|
for line in report_lines(result):
|
|
print(line)
|
|
|
|
if result.total_removed and not args.dry_run:
|
|
print("\nRun 'python scripts/generate_db.py --force' to rebuild database.")
|
|
if result.failed:
|
|
print(f"ERROR: {len(result.failed)} copies could not be removed", file=sys.stderr)
|
|
return 1
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
from core.cli import run_cli
|
|
|
|
run_cli(main)
|