chore: drop label comments across scripts

CommentsSayWhy read three scripts while 22 comments in 13 other files
named the next statement. They are removed or replaced by the reason,
and the test reads every tracked script and install.py.
This commit is contained in:
Abdessamad Derraz committed 2026-10-21 10:06:39 +02:00
1 parent b057684b94
commit d63c881648
16 files changed
+16 -28

No files matched your search

+1 -1
View File
@@ -11,7 +11,7 @@
$ErrorActionPreference = "Stop"
$defaultInstallUrl = "https://raw.githubusercontent.com/Abdess/retrobios/main/install.py"
$defaultInstallSha256 = "1cf3bd0d3985e3a728513be75cb80682fe1e7a9224da6437e8f1cd9b2a3eedb1"
$defaultInstallSha256 = "60702ddec35b2edd38ca73b94cfc6bb80da7c53759304d3a04e2e80f62228344"
$maximumInstallerBytes = 2MB
$installerExit = 0
$installer = if ($PSScriptRoot) { Join-Path $PSScriptRoot "install.py" } else { $null }
+1 -2
View File
@@ -3758,7 +3758,6 @@ def do_standalone_copies(
break
continue
# Resolve source files
if "pattern" in entry:
sources = [
f for f in bios_path.rglob("*")
@@ -3774,7 +3773,7 @@ def do_standalone_copies(
if not sources:
continue
# Resolve target directories with WSL fallback
# WSL installs where Linux does unless the entry names WSL targets.
targets = entry.get("targets", {}).get(os_type, [])
if not targets and os_type == "wsl":
targets = entry.get("targets", {}).get("linux", [])
+1 -1
View File
@@ -18,7 +18,7 @@ esac
TEMP_INSTALLER=""
TEMP_DIRECTORY=""
DEFAULT_INSTALL_URL="https://raw.githubusercontent.com/Abdess/retrobios/main/install.py"
DEFAULT_INSTALL_SHA256="1cf3bd0d3985e3a728513be75cb80682fe1e7a9224da6437e8f1cd9b2a3eedb1"
DEFAULT_INSTALL_SHA256="60702ddec35b2edd38ca73b94cfc6bb80da7c53759304d3a04e2e80f62228344"
MAX_INSTALLER_BYTES=2097152
cleanup() {
-1
View File
@@ -263,7 +263,6 @@ def load_platform_config(platform_name: str, platforms_dir: str = "platforms") -
config, chain = _inherited_yaml(platform_name, platforms_dir)
# Resolve shared group includes
shared_path = os.path.join(platforms_dir, "_shared.yml")
# Merge metadata from _registry.yml. The registry is our curated source,
# while the scraped YAML may be incomplete (missing cores, metadata fields).
-2
View File
@@ -706,7 +706,6 @@ def _cross_reference_profile(
seen_files.add(seen_key)
# Group archived files by archive name
if archive:
archive_key = (
archive,
@@ -771,7 +770,6 @@ def _cross_reference_profile(
}
gaps.append(entry)
# Append grouped archive gaps
for ag in sorted(archive_gaps.values(), key=lambda e: e["name"]):
gaps.append(ag)
-1
View File
@@ -250,7 +250,6 @@ def verify_secure_info_a(
if serial == b"\x00" * 15:
return False, "invalid: serial_number is all zeros"
# Get RSA keys
rsa_keys = keys.get("RSA", {})
modulus = rsa_keys.get("secureInfoMod")
exponent = rsa_keys.get("secureInfoExp")
-1
View File
@@ -291,7 +291,6 @@ def deduplicate(bios_dir: str, dry_run: bool = False) -> dict:
if not dry_run and empty_cleaned:
print(f"Cleaned {empty_cleaned} empty directories")
# Write MAME clone mapping
if mame_clones:
# A group is only visible while both copies are on disk, and this run
# has just deleted the clone. Writing only what was seen this time
-3
View File
@@ -993,7 +993,6 @@ def generate_pack(
agnostic_resolved = True
if agnostic_resolved and local_path:
# Write rename README
original_name = os.path.basename(local_path)
dest_name = file_entry.get("name", "")
if original_name != dest_name and agnostic_path:
@@ -1537,7 +1536,6 @@ def generate_emulator_pack(
if not files and not profile.get("data_directories"):
print(f" No files needed for {profile.get('emulator', emu_name)}")
# Collect archives as atomic units
archives: set[str] = set()
for fe in files:
archive = fe.get("archive")
@@ -4103,7 +4101,6 @@ def generate_manifest(
repo_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Filter systems by target
plat_cores = _platform_cores(config, emu_profiles) if target_cores else None
pack_systems = filter_systems_by_target(
config.get("systems", {}),
-1
View File
@@ -443,7 +443,6 @@ def _patch_bios_entries(text: str, files: list[dict]) -> str:
"""
import re
# Build a lookup of what to patch
patches: dict[str, dict] = {}
for fe in files:
if fe.get("category") != "bios_zip":
-1
View File
@@ -444,7 +444,6 @@ class Scraper(BaseScraper):
"""Generate a platform YAML config dict from scraped data."""
requirements = self.fetch_requirements()
# Parse source to extract display names per system
raw = self._fetch_raw()
source_dict = self._extract_systems_dict(raw)
display_names: dict[str, str] = {}
-2
View File
@@ -214,7 +214,6 @@ def parse_firmware_database(
r"\s*\)"
)
# Collect firmware slots
firmware_slots: dict[tuple[str, str], str] = {}
for m in firmware_re.finditer(source):
system, fw_id, desc = m.group(1), m.group(2), m.group(3)
@@ -252,7 +251,6 @@ def parse_firmware_database(
slot_key = (system, fw_id)
slot_options.setdefault(slot_key, []).append((file_entry, status))
# Build records from FirmwareAndOption one-liners
records: list[dict] = []
for m in fao_re.finditer(source):
+1 -2
View File
@@ -372,13 +372,12 @@ def _parse_rom_entries(block: str) -> list[dict]:
("rom_load", _ROM_LOAD),
]
# Collect all matches with their positions
events: list[tuple[int, str, re.Match]] = []
for tag, pat in token_patterns:
for m in pat.finditer(block):
events.append((m.start(), tag, m))
# Sort by position in block
# Walked in source order: a ROM_LOAD belongs to the last ROM_REGION above it.
events.sort(key=lambda e: e[0])
for _pos, tag, m in events:
-1
View File
@@ -230,7 +230,6 @@ class Scraper(BaseScraper):
"""Generate a platform YAML config dict from scraped data."""
requirements = self.fetch_requirements()
# Parse source to extract display names per system
raw = self._fetch_raw()
source_data = json.loads(raw)
display_names: dict[str, str] = {}
-1
View File
@@ -380,7 +380,6 @@ class Scraper(BaseScraper):
if system is None:
continue
# Resolve path
paths_raw = entry.get("paths")
if isinstance(paths_raw, str):
resolved = _resolve_path(paths_raw)
+3 -6
View File
@@ -212,11 +212,9 @@ def ecdsa_verify_sha256(
if len(public_key_xy) != 60:
return False
# Parse signature
r = int.from_bytes(signature_rs[:30], "big")
s = int.from_bytes(signature_rs[30:], "big")
# Parse public key
qx = int.from_bytes(public_key_xy[:30], "big")
qy = int.from_bytes(public_key_xy[30:], "big")
q_point = (qx, qy)
@@ -225,21 +223,20 @@ def ecdsa_verify_sha256(
if not (1 <= r < _N and 1 <= s < _N):
return False
# Compute hash
h = hashlib.sha256(message).digest()
e = int.from_bytes(h, "big")
# Truncate to bit length of n
if 256 > _N_BITLEN:
e >>= 256 - _N_BITLEN
# Compute w = s^(-1) mod n
# w = s^(-1) mod n
w = _modinv(s, _N)
# Compute u1 = e*w mod n, u2 = r*w mod n
# u1 = e*w mod n, u2 = r*w mod n
u1 = (e * w) % _N
u2 = (r * w) % _N
# Compute R = u1*G + u2*Q
# R = u1*G + u2*Q
g_point = (_Gx, _Gy)
r_point = _ec_add(_ec_mul(u1, g_point), _ec_mul(u2, q_point))
+9 -2
View File
@@ -6242,9 +6242,16 @@ class CommentsSayWhy(unittest.TestCase):
REASON = re.compile(r"\b(for|only|so|because|if|when|unless|before|after)\b")
def test_no_label_comment_restates_the_next_line(self):
"""Three scripts were read, and 22 labels stood in 13 others."""
tracked = subprocess.run(
["git", "ls-files", "--", "scripts/*.py", "scripts/**/*.py", "install.py"],
cwd=ROOT, capture_output=True, text=True, check=True,
).stdout.split()
self.assertIn("install.py", tracked)
self.assertIn("scripts/scraper/mame_parser.py", tracked)
found = []
for name in ("verify.py", "generate_site.py", "generate_truth.py"):
lines = (ROOT / "scripts" / name).read_text(encoding="utf-8").splitlines()
for name in sorted(set(tracked)):
lines = (ROOT / name).read_text(encoding="utf-8").splitlines()
for index, line in enumerate(lines):
if not self.LABEL.match(line) or self.REASON.search(line):
continue