ines-parser 1.3.0__tar.gz → 1.5.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (24) hide show
  1. {ines_parser-1.3.0 → ines_parser-1.5.0}/PKG-INFO +24 -6
  2. {ines_parser-1.3.0 → ines_parser-1.5.0}/README.md +22 -4
  3. {ines_parser-1.3.0 → ines_parser-1.5.0}/ines_parser/__init__.py +27 -3
  4. ines_parser-1.5.0/ines_parser/cli/ines_analyze_rom.py +329 -0
  5. {ines_parser-1.3.0 → ines_parser-1.5.0}/ines_parser/cli/ines_rom_stats.py +4 -5
  6. {ines_parser-1.3.0 → ines_parser-1.5.0}/ines_parser/cli/ines_scan_roms.py +93 -28
  7. {ines_parser-1.3.0 → ines_parser-1.5.0}/ines_parser/cli/ines_split_rom.py +6 -7
  8. {ines_parser-1.3.0 → ines_parser-1.5.0}/ines_parser/cli/rom_fs.py +2 -3
  9. ines_parser-1.5.0/ines_parser/filename.py +397 -0
  10. ines_parser-1.5.0/ines_parser/mappers.py +24 -0
  11. {ines_parser-1.3.0 → ines_parser-1.5.0}/ines_parser/parser.py +18 -1
  12. ines_parser-1.5.0/ines_parser/py.typed +0 -0
  13. ines_parser-1.3.0/ines_parser/mappers.py → ines_parser-1.5.0/ines_parser/tables.py +322 -10
  14. {ines_parser-1.3.0 → ines_parser-1.5.0}/ines_parser.egg-info/PKG-INFO +24 -6
  15. {ines_parser-1.3.0 → ines_parser-1.5.0}/ines_parser.egg-info/SOURCES.txt +6 -1
  16. {ines_parser-1.3.0 → ines_parser-1.5.0}/ines_parser.egg-info/entry_points.txt +1 -0
  17. {ines_parser-1.3.0 → ines_parser-1.5.0}/pyproject.toml +3 -2
  18. ines_parser-1.5.0/tests/test_filename.py +292 -0
  19. {ines_parser-1.3.0 → ines_parser-1.5.0}/LICENSE +0 -0
  20. {ines_parser-1.3.0 → ines_parser-1.5.0}/ines_parser/cli/__init__.py +0 -0
  21. {ines_parser-1.3.0 → ines_parser-1.5.0}/ines_parser.egg-info/dependency_links.txt +0 -0
  22. {ines_parser-1.3.0 → ines_parser-1.5.0}/ines_parser.egg-info/requires.txt +0 -0
  23. {ines_parser-1.3.0 → ines_parser-1.5.0}/ines_parser.egg-info/top_level.txt +0 -0
  24. {ines_parser-1.3.0 → ines_parser-1.5.0}/setup.cfg +0 -0
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ines-parser
3
- Version: 1.3.0
4
- Summary: Parse iNES/NES 2.0 ROM headers; CLI to scan, export, summarize, and split ROMs
3
+ Version: 1.5.0
4
+ Summary: Parse iNES/NES 2.0 ROM headers and ROM filename tags; CLI to scan, export, summarize, analyze, and split ROMs
5
5
  Author: Leonid Kabanov
6
6
  License-Expression: MIT
7
7
  Project-URL: Homepage, https://github.com/ponchick/ines-parser
@@ -28,7 +28,7 @@ Dynamic: license-file
28
28
 
29
29
  # iNES Parser
30
30
 
31
- Python library and CLI for NES ROMs in iNES / NES 2.0 format: parse headers, scan collections, export reports, summarize mappers, and split PRG/CHR. Requires Python 3.10+.
31
+ Python library and CLI for NES ROMs in iNES / NES 2.0 format: parse headers and ROM filename tags, scan collections, export reports, summarize mappers, analyze single ROMs, and split PRG/CHR. Requires Python 3.10+.
32
32
 
33
33
  ```bash
34
34
  pip install ines-parser
@@ -44,7 +44,7 @@ ines_scan_roms.py /path/to/roms
44
44
  # or: python -m ines_parser.cli.ines_scan_roms /path/to/roms
45
45
  ```
46
46
 
47
- Same idea for `ines_rom_stats.py` and `ines_split_rom.py`.
47
+ Same idea for `ines_rom_stats.py`, `ines_split_rom.py`, and `ines_analyze_rom.py`.
48
48
 
49
49
  ### Scan
50
50
 
@@ -74,10 +74,19 @@ ines_split_rom.py game.nes
74
74
  ines_split_rom.py roms.7z # prompts before overwrite; use --force to skip
75
75
  ```
76
76
 
77
+ ### Analyze
78
+
79
+ ```bash
80
+ ines_analyze_rom.py game.nes
81
+ ines_analyze_rom.py game.nes --json
82
+ ```
83
+
84
+ Full report for one ROM file: file size, iNES header, and naming-convention tags parsed from the filename — GoodTools style (`(JU) [!] [b] [hIR] [T+Rus] (VS) (PC10)`) and No-Intro style (`(USA) (Rev A) (Beta 1) (En,Fr,De)`) — plus cross-checks between them: file size vs. header, filename region vs. TV system, `(VS)`/`(PC10)` vs. console type, `[!]` vs. header validity. Unrecognised tags are listed as unknown, never guessed.
85
+
77
86
  ## Library
78
87
 
79
88
  ```python
80
- from ines_parser import parse_ines_header
89
+ from ines_parser import parse_ines_header, parse_rom_filename
81
90
 
82
91
  with open("game.nes", "rb") as f:
83
92
  header = parse_ines_header(f.read(16))
@@ -85,11 +94,20 @@ with open("game.nes", "rb") as f:
85
94
  if header and header.is_valid():
86
95
  print(header)
87
96
  print(header.detailed_str())
97
+
98
+ info = parse_rom_filename("Super Mario Bros. (JU) [!].nes")
99
+ print(info.title) # Super Mario Bros.
100
+ print(info.regions) # ('Japan', 'USA')
101
+ print(info.verified) # True
102
+ print(info.to_dict()) # JSON-friendly; adds expected_tv_system
88
103
  ```
89
104
 
90
105
  ## Docs
91
106
 
92
- - `docs/iNES.md`
107
+ - `docs/iNES.md` — iNES header notes
108
+ - `docs/NES2.0.md` — NES 2.0 header layout
109
+ - `docs/List of iNES mappers.md` — mapper and submapper name tables (from `ines_parser/tables.py`)
110
+ - `docs/NES 2.0 lookups.md` — Vs. PPU/hardware, extended console, expansion device names
93
111
  - [NESdev iNES](https://www.nesdev.org/wiki/INES)
94
112
  - [NESdev NES 2.0](https://www.nesdev.org/wiki/NES_2.0)
95
113
 
@@ -1,6 +1,6 @@
1
1
  # iNES Parser
2
2
 
3
- Python library and CLI for NES ROMs in iNES / NES 2.0 format: parse headers, scan collections, export reports, summarize mappers, and split PRG/CHR. Requires Python 3.10+.
3
+ Python library and CLI for NES ROMs in iNES / NES 2.0 format: parse headers and ROM filename tags, scan collections, export reports, summarize mappers, analyze single ROMs, and split PRG/CHR. Requires Python 3.10+.
4
4
 
5
5
  ```bash
6
6
  pip install ines-parser
@@ -16,7 +16,7 @@ ines_scan_roms.py /path/to/roms
16
16
  # or: python -m ines_parser.cli.ines_scan_roms /path/to/roms
17
17
  ```
18
18
 
19
- Same idea for `ines_rom_stats.py` and `ines_split_rom.py`.
19
+ Same idea for `ines_rom_stats.py`, `ines_split_rom.py`, and `ines_analyze_rom.py`.
20
20
 
21
21
  ### Scan
22
22
 
@@ -46,10 +46,19 @@ ines_split_rom.py game.nes
46
46
  ines_split_rom.py roms.7z # prompts before overwrite; use --force to skip
47
47
  ```
48
48
 
49
+ ### Analyze
50
+
51
+ ```bash
52
+ ines_analyze_rom.py game.nes
53
+ ines_analyze_rom.py game.nes --json
54
+ ```
55
+
56
+ Full report for one ROM file: file size, iNES header, and naming-convention tags parsed from the filename — GoodTools style (`(JU) [!] [b] [hIR] [T+Rus] (VS) (PC10)`) and No-Intro style (`(USA) (Rev A) (Beta 1) (En,Fr,De)`) — plus cross-checks between them: file size vs. header, filename region vs. TV system, `(VS)`/`(PC10)` vs. console type, `[!]` vs. header validity. Unrecognised tags are listed as unknown, never guessed.
57
+
49
58
  ## Library
50
59
 
51
60
  ```python
52
- from ines_parser import parse_ines_header
61
+ from ines_parser import parse_ines_header, parse_rom_filename
53
62
 
54
63
  with open("game.nes", "rb") as f:
55
64
  header = parse_ines_header(f.read(16))
@@ -57,11 +66,20 @@ with open("game.nes", "rb") as f:
57
66
  if header and header.is_valid():
58
67
  print(header)
59
68
  print(header.detailed_str())
69
+
70
+ info = parse_rom_filename("Super Mario Bros. (JU) [!].nes")
71
+ print(info.title) # Super Mario Bros.
72
+ print(info.regions) # ('Japan', 'USA')
73
+ print(info.verified) # True
74
+ print(info.to_dict()) # JSON-friendly; adds expected_tv_system
60
75
  ```
61
76
 
62
77
  ## Docs
63
78
 
64
- - `docs/iNES.md`
79
+ - `docs/iNES.md` — iNES header notes
80
+ - `docs/NES2.0.md` — NES 2.0 header layout
81
+ - `docs/List of iNES mappers.md` — mapper and submapper name tables (from `ines_parser/tables.py`)
82
+ - `docs/NES 2.0 lookups.md` — Vs. PPU/hardware, extended console, expansion device names
65
83
  - [NESdev iNES](https://www.nesdev.org/wiki/INES)
66
84
  - [NESdev NES 2.0](https://www.nesdev.org/wiki/NES_2.0)
67
85
 
@@ -2,7 +2,8 @@
2
2
  iNES Parser Library
3
3
 
4
4
  A Python library for parsing iNES format NES ROM files.
5
- Supports iNES 1.0, NES 2.0, Archaic iNES formats, and UNIF detection.
5
+ Supports iNES 1.0, NES 2.0, Archaic iNES formats, and UNIF detection,
6
+ plus GoodTools/No-Intro ROM filename conventions.
6
7
  """
7
8
 
8
9
  from .parser import (
@@ -17,15 +18,28 @@ from .parser import (
17
18
  INES_TRAINER_SIZE,
18
19
  )
19
20
 
20
- from .mappers import (
21
+ from .filename import (
22
+ parse_rom_filename,
23
+ RomFilenameInfo,
24
+ DumpStatus,
25
+ expected_tv_system,
26
+ )
27
+
28
+ from .tables import (
21
29
  get_mapper_name,
22
30
  get_mapper_alternate_names,
23
31
  get_mapper_notes,
24
32
  get_mapper_info,
25
33
  is_known_mapper,
34
+ get_vs_ppu_type_name,
35
+ get_vs_hw_type_name,
36
+ get_extended_console_type_name,
37
+ get_expansion_device_name,
38
+ get_submapper_name,
39
+ is_known_submapper,
26
40
  )
27
41
 
28
- __version__ = "1.3.0"
42
+ __version__ = "1.5.0"
29
43
  __author__ = "Leonid Kabanov"
30
44
  __all__ = [
31
45
  "parse_ines_header",
@@ -37,10 +51,20 @@ __all__ = [
37
51
  "CPUTiming",
38
52
  "INES_HEADER_SIZE",
39
53
  "INES_TRAINER_SIZE",
54
+ "parse_rom_filename",
55
+ "RomFilenameInfo",
56
+ "DumpStatus",
57
+ "expected_tv_system",
40
58
  "get_mapper_name",
41
59
  "get_mapper_alternate_names",
42
60
  "get_mapper_notes",
43
61
  "get_mapper_info",
44
62
  "is_known_mapper",
63
+ "get_vs_ppu_type_name",
64
+ "get_vs_hw_type_name",
65
+ "get_extended_console_type_name",
66
+ "get_expansion_device_name",
67
+ "get_submapper_name",
68
+ "is_known_submapper",
45
69
  ]
46
70
 
@@ -0,0 +1,329 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ Full analysis of a single iNES ROM file.
4
+
5
+ Combines three sources of information about one ROM:
6
+
7
+ - the file itself (size),
8
+ - the iNES / NES 2.0 header,
9
+ - the filename's naming-convention tags (GoodTools / No-Intro style),
10
+
11
+ and cross-checks them against each other: file size vs. header sizes,
12
+ filename region vs. header TV system, (VS)/(PC10) markers vs. header console
13
+ type, [!] verified marker vs. header validity.
14
+ """
15
+
16
+ from __future__ import annotations
17
+
18
+ import argparse
19
+ import json
20
+ import sys
21
+ from pathlib import Path
22
+ from typing import Any
23
+
24
+ sys.path.insert(0, str(Path(__file__).resolve().parents[2]))
25
+
26
+ from ines_parser import (
27
+ INES_HEADER_SIZE,
28
+ INES_TRAINER_SIZE,
29
+ ConsoleType,
30
+ INESFormat,
31
+ INESHeader,
32
+ parse_ines_header,
33
+ )
34
+ from ines_parser.filename import RomFilenameInfo, expected_tv_system, parse_rom_filename
35
+
36
+
37
+ def format_size(size_bytes: int) -> str:
38
+ return f"{size_bytes} bytes ({size_bytes / 1024:.1f} KiB)"
39
+
40
+
41
+ def analyze_file(path: Path) -> dict[str, Any]:
42
+ """Build the full report dict for one ROM file."""
43
+ file_size = path.stat().st_size
44
+ with open(path, "rb") as f:
45
+ raw_header = f.read(INES_HEADER_SIZE)
46
+
47
+ header: INESHeader | None = None
48
+ header_dict: dict[str, Any] | None
49
+ if len(raw_header) < INES_HEADER_SIZE:
50
+ header_dict = {
51
+ "valid": False,
52
+ "error": f"file too short for a {INES_HEADER_SIZE}-byte header",
53
+ }
54
+ else:
55
+ header = parse_ines_header(raw_header)
56
+ header_dict = header.to_dict() if header is not None else None
57
+
58
+ name_info = parse_rom_filename(path.name)
59
+
60
+ return {
61
+ "schema_version": 1,
62
+ "file": {
63
+ "path": str(path),
64
+ "size_bytes": file_size,
65
+ },
66
+ "filename": name_info.to_dict(),
67
+ "header": header_dict,
68
+ "cross_checks": build_cross_checks(name_info, header, file_size),
69
+ # Runtime-only helpers for the text renderer; stripped from JSON output.
70
+ "_filename_info": name_info,
71
+ "_header_object": header,
72
+ }
73
+
74
+
75
+ def _check(name: str, status: str, detail: str) -> dict[str, str]:
76
+ return {"check": name, "status": status, "detail": detail}
77
+
78
+
79
+ def build_cross_checks(
80
+ name_info: RomFilenameInfo,
81
+ header: INESHeader | None,
82
+ file_size: int,
83
+ ) -> list[dict[str, str]]:
84
+ """Compare filename facts, header fields and the actual file size."""
85
+ checks: list[dict[str, str]] = []
86
+ header_valid = header is not None and header.is_valid()
87
+
88
+ # --- File size vs sizes declared in the header ---
89
+ if header is not None and header.is_valid():
90
+ expected = (
91
+ INES_HEADER_SIZE
92
+ + (INES_TRAINER_SIZE if header.has_trainer else 0)
93
+ + header.prg_rom_size
94
+ + header.chr_rom_size
95
+ )
96
+ parts = [
97
+ f"{INES_HEADER_SIZE} header",
98
+ f"{header.prg_rom_size} PRG",
99
+ f"{header.chr_rom_size} CHR",
100
+ ]
101
+ if header.has_trainer:
102
+ parts.insert(1, f"{INES_TRAINER_SIZE} trainer")
103
+ composition = " + ".join(parts)
104
+ if header.misc_rom_count:
105
+ checks.append(_check(
106
+ "file size vs header",
107
+ "skipped",
108
+ "header declares miscellaneous ROMs of unstated size",
109
+ ))
110
+ elif file_size == expected:
111
+ checks.append(_check(
112
+ "file size vs header", "ok", f"exactly {composition}"
113
+ ))
114
+ elif file_size > expected:
115
+ checks.append(_check(
116
+ "file size vs header",
117
+ "warning",
118
+ f"{file_size - expected} trailing byte(s) beyond {composition}",
119
+ ))
120
+ else:
121
+ checks.append(_check(
122
+ "file size vs header",
123
+ "warning",
124
+ f"file is {expected - file_size} byte(s) shorter than {composition}",
125
+ ))
126
+
127
+ # --- Filename region vs header TV system ---
128
+ tv_system = header.tv_system
129
+ if tv_system is not None:
130
+ note = "" if header.format == INESFormat.NES_2_0 else \
131
+ " (iNES 1.0 TV bits are unofficial)"
132
+ expected_tv = expected_tv_system(name_info.regions)
133
+ if not name_info.regions:
134
+ checks.append(_check(
135
+ "filename region vs TV system",
136
+ "skipped",
137
+ "no region tags in the filename",
138
+ ))
139
+ elif expected_tv is None:
140
+ checks.append(_check(
141
+ "filename region vs TV system",
142
+ "skipped",
143
+ f"regions {', '.join(name_info.regions)} do not imply a single TV system",
144
+ ))
145
+ elif tv_system.value not in ("NTSC", "PAL"):
146
+ checks.append(_check(
147
+ "filename region vs TV system",
148
+ "skipped",
149
+ f"header TV system {tv_system.value} is not directly comparable",
150
+ ))
151
+ elif expected_tv == tv_system.value:
152
+ checks.append(_check(
153
+ "filename region vs TV system",
154
+ "ok",
155
+ f"{', '.join(name_info.regions)} imply {expected_tv}; "
156
+ f"header says {tv_system.value}{note}",
157
+ ))
158
+ else:
159
+ checks.append(_check(
160
+ "filename region vs TV system",
161
+ "warning",
162
+ f"{', '.join(name_info.regions)} imply {expected_tv}, "
163
+ f"but header says {tv_system.value}{note}",
164
+ ))
165
+
166
+ # --- (VS) / (PC10) filename markers vs header console type ---
167
+ header_is_vs = (
168
+ header.console_type == ConsoleType.VS_SYSTEM or header.is_vs_unisystem
169
+ )
170
+ if name_info.is_vs or header_is_vs:
171
+ both = name_info.is_vs and header_is_vs
172
+ checks.append(_check(
173
+ "Vs. System marker vs header console type",
174
+ "ok" if both else "warning",
175
+ "filename (VS) and header console type agree"
176
+ if both
177
+ else "filename (VS) marker" if name_info.is_vs
178
+ else "header console type says Vs. System",
179
+ ))
180
+
181
+ header_is_pc10 = (
182
+ header.console_type == ConsoleType.PLAYCHOICE_10 or header.is_playchoice_10
183
+ )
184
+ if name_info.is_playchoice or header_is_pc10:
185
+ both = name_info.is_playchoice and header_is_pc10
186
+ checks.append(_check(
187
+ "PlayChoice-10 marker vs header console type",
188
+ "ok" if both else "warning",
189
+ "filename (PC10) and header console type agree"
190
+ if both
191
+ else "filename (PC10) marker" if name_info.is_playchoice
192
+ else "header console type says PlayChoice-10",
193
+ ))
194
+
195
+ # --- [!] verified dump vs header validity ---
196
+ if name_info.verified:
197
+ if header_valid:
198
+ checks.append(_check(
199
+ "verified dump marker vs header",
200
+ "ok",
201
+ "[!] claims a verified dump; header is a valid iNES image",
202
+ ))
203
+ else:
204
+ checks.append(_check(
205
+ "verified dump marker vs header",
206
+ "warning",
207
+ "[!] claims a verified dump, but the header is not a valid iNES image",
208
+ ))
209
+
210
+ return checks
211
+
212
+
213
+ def filename_lines(info: RomFilenameInfo) -> list[tuple[str, str]]:
214
+ """(label, value) pairs for the text report; only non-default facts."""
215
+ lines: list[tuple[str, str]] = []
216
+
217
+ def add(label: str, value: str) -> None:
218
+ lines.append((label, value))
219
+
220
+ if info.regions:
221
+ add("Regions", ", ".join(info.regions))
222
+ if info.languages:
223
+ add("Languages", ", ".join(info.languages))
224
+ add("Dump status", info.dump_status.value)
225
+ extra_flags = [f for f in info.dump_flags if f != info.dump_status.value]
226
+ if extra_flags:
227
+ add("Dump flags", ", ".join(extra_flags))
228
+ if info.is_hack:
229
+ add("Hack", f"yes ({info.hack_tag})" if info.hack_tag else "yes")
230
+ if info.is_translation:
231
+ marker = "+" if info.translation_is_newer else "-"
232
+ language = info.translation_language or "?"
233
+ add("Translation", f"[T{marker}{language}]")
234
+ if info.is_unlicensed:
235
+ add("Unlicensed", "yes")
236
+ if info.is_public_domain:
237
+ add("Public domain", "yes")
238
+ if info.is_vs:
239
+ add("Vs. System", "yes")
240
+ if info.is_playchoice:
241
+ add("PlayChoice-10", "yes")
242
+ if info.is_nintendo_power:
243
+ add("Nintendo Power", "yes")
244
+ if info.multipart_index is not None:
245
+ add("Multipart", str(info.multipart_index))
246
+ if info.prerelease:
247
+ suffix = f" {info.prerelease_index}" if info.prerelease_index else ""
248
+ add("Prerelease", f"{info.prerelease}{suffix}")
249
+ if info.revision:
250
+ add("Revision", info.revision)
251
+ if info.version:
252
+ add("Version", info.version)
253
+ return lines
254
+
255
+
256
+ def print_text_report(report: dict[str, Any]) -> None:
257
+ file_info = report["file"]
258
+ print(f"File: {file_info['path']}")
259
+ print(f"Size: {format_size(file_info['size_bytes'])}")
260
+
261
+ name_dict = report["filename"]
262
+ print("\nFilename analysis")
263
+ print(f" {'Title:':16} {name_dict['title']}")
264
+ for label, value in filename_lines(report["_filename_info"]):
265
+ print(f" {label + ':':16} {value}")
266
+ if name_dict.get("unknown_tokens"):
267
+ print(f" {'Unknown tokens:':16} {' '.join(name_dict['unknown_tokens'])}")
268
+
269
+ print("\niNES header")
270
+ header_dict = report["header"]
271
+ if header_dict is None:
272
+ print(" no header (file too short)")
273
+ elif not header_dict.get("valid"):
274
+ detail = header_dict.get("error") or header_dict.get("format", "unknown")
275
+ print(f" not a valid iNES image ({detail})")
276
+ else:
277
+ print(f" {report['_header_object'].detailed_str()}")
278
+
279
+ print("\nCross-checks")
280
+ checks = report["cross_checks"]
281
+ if not checks:
282
+ print(" (none; header not valid or nothing to compare)")
283
+ return
284
+ for check in checks:
285
+ print(f" {check['status'].upper():8} {check['check']}: {check['detail']}")
286
+
287
+
288
+ def build_argument_parser() -> argparse.ArgumentParser:
289
+ parser = argparse.ArgumentParser(
290
+ prog="ines_analyze_rom.py",
291
+ description="Full analysis of a single ROM: header, filename tags, cross-checks",
292
+ )
293
+ parser.add_argument("rom", metavar="ROM", help="Path to the ROM file (.nes)")
294
+ parser.add_argument(
295
+ "--json",
296
+ action="store_true",
297
+ help="Print machine-readable JSON instead of the text report",
298
+ )
299
+ return parser
300
+
301
+
302
+ def main() -> int:
303
+ parser = build_argument_parser()
304
+ args = parser.parse_args()
305
+
306
+ path = Path(args.rom)
307
+ if not path.exists():
308
+ print(f"Error: File does not exist: {args.rom}", file=sys.stderr)
309
+ return 1
310
+ if not path.is_file():
311
+ print(f"Error: Not a file: {args.rom}", file=sys.stderr)
312
+ return 1
313
+
314
+ try:
315
+ report = analyze_file(path)
316
+ except OSError as exc:
317
+ print(f"Error: Cannot read {args.rom}: {exc}", file=sys.stderr)
318
+ return 1
319
+
320
+ if args.json:
321
+ public = {k: v for k, v in report.items() if not k.startswith("_")}
322
+ print(json.dumps(public, indent=2))
323
+ else:
324
+ print_text_report(report)
325
+ return 0
326
+
327
+
328
+ if __name__ == "__main__":
329
+ sys.exit(main())
@@ -23,12 +23,11 @@ except ImportError:
23
23
  libarchive = None # type: ignore
24
24
 
25
25
  from ines_parser import INES_HEADER_SIZE, parse_ines_header
26
- from ines_parser.mappers import get_mapper_name
26
+ from ines_parser.tables import get_mapper_name
27
27
 
28
28
  from ines_parser.cli.rom_fs import (
29
29
  ALL_ARCHIVE_FORMATS,
30
30
  ARCHIVE_EXTENSIONS,
31
- LIBARCHIVE_AVAILABLE,
32
31
  DEFAULT_ARCHIVE_PATH,
33
32
  SUPPORTED_EXTENSIONS,
34
33
  collect_supported_files,
@@ -73,7 +72,7 @@ def tally_nes_file(file_path: Path, stats: RomStats) -> None:
73
72
 
74
73
 
75
74
  def tally_archive(archive_path: Path, stats: RomStats) -> None:
76
- if not LIBARCHIVE_AVAILABLE or libarchive is None:
75
+ if libarchive is None:
77
76
  return
78
77
  try:
79
78
  with open(archive_path, "rb") as f:
@@ -163,7 +162,7 @@ def print_text_report(report: dict[str, Any]) -> None:
163
162
 
164
163
  def build_argument_parser() -> argparse.ArgumentParser:
165
164
  supported = ", ".join(sorted(SUPPORTED_EXTENSIONS))
166
- if not LIBARCHIVE_AVAILABLE:
165
+ if libarchive is None:
167
166
  supported += " (libarchive not installed — archive members not scanned)"
168
167
 
169
168
  parser = argparse.ArgumentParser(
@@ -226,7 +225,7 @@ def main() -> int:
226
225
  for r in scan_roots:
227
226
  print(f" {r}", file=sys.stderr)
228
227
  print(f"Extensions: {', '.join(sorted(SUPPORTED_EXTENSIONS))}", file=sys.stderr)
229
- if not LIBARCHIVE_AVAILABLE:
228
+ if libarchive is None:
230
229
  print(
231
230
  f"Note: without libarchive, archives {sorted(ALL_ARCHIVE_FORMATS)} are ignored.",
232
231
  file=sys.stderr,