From fb81cb16bb19603f7fa0fff3698bdfa32b2896fc Mon Sep 17 00:00:00 2001 From: wilbertpol Date: Sat, 25 Mar 2023 14:31:09 +0000 Subject: minimaws: Let command-line romident identify media inside zip archives. (#11024) --- scripts/minimaws/lib/auxverbs.py | 12 ++++++++++-- scripts/minimaws/minimaws.py | 13 +++++++++---- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/scripts/minimaws/lib/auxverbs.py b/scripts/minimaws/lib/auxverbs.py index bff43bc9601..ac520da7d87 100644 --- a/scripts/minimaws/lib/auxverbs.py +++ b/scripts/minimaws/lib/auxverbs.py @@ -11,6 +11,7 @@ import os import os.path import struct import sys +import zipfile import zlib @@ -129,8 +130,15 @@ class _Identifier(object): def processFile(self, path): if os.path.splitext(path)[1].lower() != '.chd': - with open(path, mode='rb', buffering=0) as f: - self.processRomFile(path, f) + if zipfile.is_zipfile(path): + with zipfile.ZipFile(path, 'r') as zip: + for info in zip.namelist(): + if info.filename[-1] != '/': + with zip.open(info, mode='r') as f: + self.processRomFile(path + '/' + info.filename, f) + else: + with open(path, mode='rb', buffering=0) as f: + self.processRomFile(path, f) else: with open(path, mode='rb') as f: sha1 = self.probeChd(f) diff --git a/scripts/minimaws/minimaws.py b/scripts/minimaws/minimaws.py index 25f74eb8c68..2d91cdcf1a8 100755 --- a/scripts/minimaws/minimaws.py +++ b/scripts/minimaws/minimaws.py @@ -26,9 +26,9 @@ ## $ python minimaws.py listclones "unkch*" ## $ python minimaws.py listbrothers superx ## -## The romident command does not support archives or software lists, but -## it's far faster than using MAME as it has optimised indexes, and -## results are grouped by machine rather than by file: +## The romident command does not support 7zip archives, but it's far +## faster than using MAME as it has optimised indexes, and results are +## grouped by machine rather than by file: ## ## $ python minimaws.py romident 27c64.bin dump-dir ## @@ -36,7 +36,7 @@ ## equivalent for. The listaffected command shows all runnable machines ## that reference devices defined in specified source files: ## -## $ python minimaws.py listaffected "src/devices/cpu/m6805/*" src/devices/cpu/mcs40/mcs40.cpp +## $ python minimaws.py listaffected "devices/cpu/m6805/*" devices/cpu/mcs40/mcs40.cpp ## ## This script can also run a local web server allowing you to explore ## systems, devices and source files: @@ -77,6 +77,11 @@ ## On any of these, and many other systems, you can select slot options ## and see dependent slots update. Required command-line arguments to ## produce the selected configuration are also displayed. +## +## Media files can be identified using a web browser interface +## +## Checksums and digests are calculated locally - no files are uploaded +## to the server. if __name__ == '__main__': import argparse -- cgit v1.2.3