Added starpath cassette images & changed to binary sha1 hash instead of using hexdigest

This commit is contained in:
Rob McMullen 2018-11-08 13:38:15 -08:00
parent 738aa05921
commit f6bd90656a
4 changed files with 1908 additions and 1900 deletions

View File

@ -345,3 +345,8 @@ class RomImage(DiskImageBase):
class Atari2600CartImage(RomImage): class Atari2600CartImage(RomImage):
def __str__(self): def __str__(self):
return f"{len(self.rawdata) // 1024}k Atari 2600 Cartridge" return f"{len(self.rawdata) // 1024}k Atari 2600 Cartridge"
class Atari2600StarpathImage(RomImage):
def __str__(self):
return f"{len(self.rawdata) // 1024}k Atari 2600 Starpath Cassette"

View File

@ -6,7 +6,7 @@ from .segments import SegmentData, DefaultSegment
from .kboot import KBootImage from .kboot import KBootImage
from .ataridos import AtariDosDiskImage, BootDiskImage, AtariDosFile, XexContainerSegment, AtariDiskImage from .ataridos import AtariDosDiskImage, BootDiskImage, AtariDosFile, XexContainerSegment, AtariDiskImage
from .spartados import SpartaDosDiskImage from .spartados import SpartaDosDiskImage
from .cartridge import AtariCartImage, Atari8bitCartImage, Atari5200CartImage, get_known_carts, RomImage, Atari2600CartImage from .cartridge import AtariCartImage, Atari8bitCartImage, Atari5200CartImage, get_known_carts, RomImage, Atari2600CartImage, Atari2600StarpathImage
from .mame import MameZipImage from .mame import MameZipImage
from .dos33 import Dos33DiskImage, ProdosDiskImage, Dos33BinFile from .dos33 import Dos33DiskImage, ProdosDiskImage, Dos33BinFile
from .standard_delivery import StandardDeliveryImage from .standard_delivery import StandardDeliveryImage
@ -166,6 +166,11 @@ class Atari2600CartParser(SegmentParser):
image_type = Atari2600CartImage image_type = Atari2600CartImage
class Atari2600StarpathParser(SegmentParser):
menu_name = "Atari 2600 Starpath Cassette"
image_type = Atari2600StarpathImage
class RomParser(SegmentParser): class RomParser(SegmentParser):
menu_name = "ROM Image" menu_name = "ROM Image"
image_type = RomImage image_type = RomImage
@ -220,7 +225,7 @@ def guess_parser_by_size(r, verbose=False):
size = len(r) size = len(r)
if size in sha1_signatures: if size in sha1_signatures:
print(r) print(r)
sha_hash = hashlib.sha1(r.data).hexdigest() sha_hash = hashlib.sha1(r.data).digest()
log.info(f"{size} in signature database, attempting to match {sha_hash}") log.info(f"{size} in signature database, attempting to match {sha_hash}")
try: try:
match = sha1_signatures[size][sha_hash] match = sha1_signatures[size][sha_hash]
@ -322,6 +327,9 @@ mime_parsers = {
"application/vnd.atari2600.cart": [ "application/vnd.atari2600.cart": [
Atari2600CartParser, Atari2600CartParser,
], ],
"application/vnd.atari2600.starpath": [
Atari2600StarpathParser,
],
"application/vnd.mame_rom": [ "application/vnd.mame_rom": [
MameZipParser, MameZipParser,
], ],
@ -337,12 +345,12 @@ mime_parsers = {
], ],
} }
# Note: Atari 2600 scanning not performed here because it will match everything
mime_parse_order = [ mime_parse_order = [
"application/vnd.atari8bit.atr", "application/vnd.atari8bit.atr",
"application/vnd.atari8bit.xex", "application/vnd.atari8bit.xex",
"application/vnd.atari8bit.cart", "application/vnd.atari8bit.cart",
"application/vnd.atari5200.cart", "application/vnd.atari5200.cart",
"application/vnd.atari2600.cart",
"application/vnd.mame_rom", "application/vnd.mame_rom",
"application/vnd.apple2.dsk", "application/vnd.apple2.dsk",
"application/vnd.apple2.bin", "application/vnd.apple2.bin",
@ -355,6 +363,7 @@ pretty_mime = {
"application/vnd.atari8bit.cart": "Atari 8-bit Cartridge", "application/vnd.atari8bit.cart": "Atari 8-bit Cartridge",
"application/vnd.atari5200.cart": "Atari 5200 Cartridge", "application/vnd.atari5200.cart": "Atari 5200 Cartridge",
"application/vnd.atari2600.cart": "Atari 2600 Cartridge", "application/vnd.atari2600.cart": "Atari 2600 Cartridge",
"application/vnd.atari2600.starpath": "Atari 2600 Starpath Cassette",
"application/vnd.mame_rom": "MAME", "application/vnd.mame_rom": "MAME",
"application/vnd.rom": "ROM Image", "application/vnd.rom": "ROM Image",
"application/vnd.apple2.dsk": "Apple ][ Disk Image", "application/vnd.apple2.dsk": "Apple ][ Disk Image",

File diff suppressed because it is too large Load Diff

View File

@ -7,7 +7,7 @@ import pprint
def parse(filename, mime): def parse(filename, mime):
data = open(filename, 'rb').read() data = open(filename, 'rb').read()
h = hashlib.sha1(data).hexdigest() h = hashlib.sha1(data).digest()
name = os.path.basename(os.path.splitext(filename)[0]) name = os.path.basename(os.path.splitext(filename)[0])
return len(data), h, name return len(data), h, name
@ -38,9 +38,9 @@ if __name__ == '__main__':
for k,v in sorted(new_signatures.items()): for k,v in sorted(new_signatures.items()):
lines.append(f"{k}: {{") lines.append(f"{k}: {{")
for h,n in sorted(v.items(), key=lambda a:(a[1], a[0])): for h,n in sorted(v.items(), key=lambda a:(a[1], a[0])):
lines.append(f" '{h}': {n},") lines.append(f" {h}: {n},")
lines.append("},") lines.append("},")
lines.append("} # end sha1_signatures") lines.append("} # end sha1_signatures\n")
print("\n".join(lines)) print("\n".join(lines))
with open(source, 'w') as fh: with open(source, 'w') as fh: