# One-off: add SPDX headers (and source lines) to the repository's own files. import subprocess import sys from pathlib import Path ROOT = Path(sys.argv[1]) SPDX = "# SPDX-License-Identifier: MIT" EXTRA = { "src/a5200_python/cartridge/mappings.py": [ "# Bounty Bob and Super Cart bank rules: facts restated (no code) from MAME's", "# bus/a800/bbsb.cpp and bus/a800/a5200_supercart.cpp, BSD-3-Clause, copyright", "# Fabio Priuli and Angelo Salese; their notice is in NOTICE.", ], "scripts/build_cart_table.py": [ "# Reads MAME 0.285 hash/a5200.xml and hash/a5200.hsi (CC0-1.0); the table it", "# writes keeps that attribution in its rows and in NOTICE.", ], "src/a5200_python/acid.py": [ "# Relies on the Acid800 suite's label names and verdict codes (MIT, Copyright (C)", "# 2010-2022 Avery Lee); its notice is in NOTICE. No suite file is committed.", ], "scripts/atari800_run.py": [ "# Calls libatari800 (GPL-2.0-or-later) as an external library through its public", "# API; the key codes and state offsets below are interface facts, no code taken.", ], } files = subprocess.run( ["git", "ls-files", "*.py", "*.sh", "*.toml"], cwd=ROOT, capture_output=True, text=True, check=True, ).stdout.split() for name in files: path = ROOT / name lines = path.read_text("utf-8").splitlines(keepends=True) if any("SPDX-License-Identifier" in ln for ln in lines[:4]): continue at = 1 if lines and lines[0].startswith("#!") else 0 add = [SPDX + "\n"] + [ln + "\n" for ln in EXTRA.get(name, [])] path.write_text("".join(lines[:at] + add + lines[at:]), "utf-8") print("header:", name)