From 911ef947ca273ad3bf5a00776edd2458e6de97dd Mon Sep 17 00:00:00 2001 From: "Keith F. Kelly" Date: Thu, 1 Aug 2024 16:19:58 -0700 Subject: [PATCH 1/4] increment point version --- pyproject.toml | 2 +- verifydump/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 2f2760b..368a2e9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "verifydump" -version = "1.0.0" +version = "1.0.1" description = "A tool for verifying compressed (.chd/.rvz) disc dumps against a Datfile" license = "MIT" authors = ["j68k"] diff --git a/verifydump/__init__.py b/verifydump/__init__.py index 3dc1f76..5c4105c 100644 --- a/verifydump/__init__.py +++ b/verifydump/__init__.py @@ -1 +1 @@ -__version__ = "0.1.0" +__version__ = "1.0.1" From d5d9406fe7c79be76b77edd9b3264332cd27624f Mon Sep 17 00:00:00 2001 From: "Keith F. Kelly" Date: Thu, 1 Aug 2024 16:20:49 -0700 Subject: [PATCH 2/4] handle square brackets in folder/file names by using glob.encode() --- verifydump/convert.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/verifydump/convert.py b/verifydump/convert.py index 5befbe8..bd1ed9c 100644 --- a/verifydump/convert.py +++ b/verifydump/convert.py @@ -1,3 +1,4 @@ +import glob import logging import os import pathlib @@ -53,9 +54,10 @@ def normalize_redump_bincue_dump(cue_file_path: pathlib.Path): dump_path = cue_file_path.parent dump_name = cue_file_path.stem - has_multiple_tracks = len(list(dump_path.glob(f"{dump_name} (Track *).bin"))) > 1 + tracks = list(dump_path.glob(glob.escape(dump_name) + " (Track *).bin")) + has_multiple_tracks = len(tracks) > 1 if not has_multiple_tracks: - original_bin_name = f"{dump_name} (Track 1).bin" + original_bin_name = pathlib.Path(tracks[0]).name single_track_bin_name = f"{dump_name}.bin" logging.debug(f'Renaming "{original_bin_name}" to "{single_track_bin_name}" because there is only one .bin file in the dump') @@ -90,7 +92,7 @@ def convert_chd_to_bin_gdi(chd_file_path: pathlib.Path, output_folder_path: path def normalize_redump_bin_gdi_dump(cue_file_path: pathlib.Path): game_name = cue_file_path.stem - bin_and_raw_file_paths = list(cue_file_path.parent.glob(f"{game_name}*.bin")) + list(cue_file_path.parent.glob(f"{game_name}*.raw")) + bin_and_raw_file_paths = list(cue_file_path.parent.glob(glob.escape(game_name) + "*.bin")) + list(cue_file_path.parent.glob(glob.escape(game_name) + "*.raw")) redump_bin_filename_format = get_redump_bin_filename_format(game_name, len(bin_and_raw_file_paths)) track_number_parser = re.compile(f"^{re.escape(game_name)}(?P[0-9]+)\\.(?:bin|raw)$") From 9bd5cd6c3add59de43a7612c2a192308fda43dc8 Mon Sep 17 00:00:00 2001 From: "Keith F. Kelly" Date: Thu, 1 Aug 2024 16:21:54 -0700 Subject: [PATCH 3/4] always show problems along the way, and format the list of possible name roms to be more readable --- verifydump/verify.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/verifydump/verify.py b/verifydump/verify.py index 16a2a2a..87a59af 100644 --- a/verifydump/verify.py +++ b/verifydump/verify.py @@ -110,8 +110,8 @@ def verify_redump_dump_folder(dump_folder: pathlib.Path, dat: Dat, extra_cue_sou rom_with_matching_sha1_and_name = next((rom for rom in roms_with_matching_sha1 if rom.name == dump_file_path.name), None) if not rom_with_matching_sha1_and_name: - list_of_rom_names_that_match_sha1 = " or ".join([f'"{rom.name}"' for rom in roms_with_matching_sha1]) - raise VerificationException(f'Dump file "{dump_file_path.name}" found in Dat, but it should be named {list_of_rom_names_that_match_sha1}') + list_of_rom_names_that_match_sha1 = "\n\t".join(sorted([f'"{rom.name}"' for rom in roms_with_matching_sha1])) + raise VerificationException(f'Dump file "{dump_file_path.name}" found in Dat, but it should be named one of the following:\n\t{list_of_rom_names_that_match_sha1}') if rom_with_matching_sha1_and_name.size != dump_file_path.stat().st_size: print(f"{rom_with_matching_sha1_and_name.size} {dump_file_path.stat().st_size}") @@ -243,8 +243,10 @@ def verify_dump_if_format_is_supported(dump_path: pathlib.Path, error_if_unsuppo elif error_if_unsupported: raise VerificationException(f'{pathlib.Path(sys.argv[0]).stem} doesn\'t know how to handle "{suffix_lower}" dumps') except VerificationException as e: + logging.error(str(e)) errors.append(e) except ConversionException as e: + logging.error(str(e)) errors.append(e) for dump_file_or_folder_path in dump_file_or_folder_paths: From 2f0735079fff8d73c54da83161127675285f96bb Mon Sep 17 00:00:00 2001 From: "Keith F. Kelly" Date: Thu, 1 Aug 2024 17:49:58 -0700 Subject: [PATCH 4/4] handle single bin track that already has the correct filename --- verifydump/convert.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/verifydump/convert.py b/verifydump/convert.py index bd1ed9c..ebbb8c2 100644 --- a/verifydump/convert.py +++ b/verifydump/convert.py @@ -54,22 +54,23 @@ def normalize_redump_bincue_dump(cue_file_path: pathlib.Path): dump_path = cue_file_path.parent dump_name = cue_file_path.stem - tracks = list(dump_path.glob(glob.escape(dump_name) + " (Track *).bin")) - has_multiple_tracks = len(tracks) > 1 - if not has_multiple_tracks: + tracks = list(dump_path.glob(glob.escape(dump_name) + "*.bin")) + has_single_track = len(tracks) == 1 + if has_single_track: original_bin_name = pathlib.Path(tracks[0]).name single_track_bin_name = f"{dump_name}.bin" - logging.debug(f'Renaming "{original_bin_name}" to "{single_track_bin_name}" because there is only one .bin file in the dump') + if original_bin_name != single_track_bin_name: + logging.debug(f'Renaming "{original_bin_name}" to "{single_track_bin_name}" because there is only one .bin file in the dump') - os.rename( - pathlib.Path(dump_path, original_bin_name), - pathlib.Path(dump_path, single_track_bin_name), - ) + os.rename( + pathlib.Path(dump_path, original_bin_name), + pathlib.Path(dump_path, single_track_bin_name), + ) - cue_file_path.write_text(cue_file_path.read_text().replace(f'FILE "{original_bin_name}"', f'FILE "{single_track_bin_name}"'), newline="\r\n") + cue_file_path.write_text(cue_file_path.read_text().replace(f'FILE "{original_bin_name}"', f'FILE "{single_track_bin_name}"'), newline="\r\n") - is_cue_iso_compatible = not has_multiple_tracks and re.match(r'^\s*FILE\s+"' + re.escape(f"{dump_name}.bin") + r'"\s*BINARY\s+TRACK 01 MODE1/2048\s+INDEX 01 00:00:00\s*$', cue_file_path.read_text()) + is_cue_iso_compatible = has_single_track and re.match(r'^\s*FILE\s+"' + re.escape(f"{dump_name}.bin") + r'"\s*BINARY\s+TRACK 01 MODE1/2048\s+INDEX 01 00:00:00\s*$', cue_file_path.read_text()) if is_cue_iso_compatible: logging.debug(f'"{cue_file_path.name}" is .iso compatible so converting dump to .iso and discarding .cue')