mirror of
https://github.com/robmcmullen/atrcopy.git
synced 2024-11-29 11:51:14 +00:00
Added UnsupportedDiskImage error to show that the disk has a known format but it's not able to be parsed
This commit is contained in:
parent
e38b94fc0c
commit
5f9acaa802
@ -46,6 +46,7 @@ def process(image, dirent, options):
|
||||
print dirent
|
||||
|
||||
def find_diskimage(filename):
|
||||
try:
|
||||
with open(filename, "rb") as fh:
|
||||
if options.verbose:
|
||||
print "Loading file %s" % filename
|
||||
@ -63,6 +64,10 @@ def find_diskimage(filename):
|
||||
break
|
||||
if parser is None:
|
||||
print "%s: Unknown disk image type" % filename
|
||||
except UnsupportedDiskImage, e:
|
||||
print "%s: %s" % (filename, e)
|
||||
return None
|
||||
else:
|
||||
parser.image.filename = filename
|
||||
parser.image.ext = ""
|
||||
return parser
|
||||
@ -219,7 +224,19 @@ def run():
|
||||
if options.all and file_list:
|
||||
raise AtrError("Specifying a list of files and --all doesn't make sense.")
|
||||
|
||||
image_files = []
|
||||
for filename in options.files:
|
||||
if filename == "-":
|
||||
import fileinput
|
||||
|
||||
for line in fileinput.input(["-"]):
|
||||
line = line.rstrip()
|
||||
print "-->%s<--" % line
|
||||
image_files.append(line)
|
||||
else:
|
||||
image_files.append(filename)
|
||||
|
||||
for filename in image_files:
|
||||
parser = find_diskimage(filename)
|
||||
if parser and parser.image:
|
||||
if options.all:
|
||||
|
@ -602,4 +602,13 @@ class ProdosDiskImage(DiskImageBase):
|
||||
if prodos == "PRODOS":
|
||||
swap_order = True
|
||||
else:
|
||||
raise InvalidDiskImage("No ProDOS header info found")
|
||||
# FIXME: this doesn't seem to be the only way to identify a
|
||||
# PRODOS disk. I have example images where PRODOS occurs at
|
||||
# 0x21 - 0x27 in t0s14 and 0x11 - 0x16 in t0s01. Using 3 -
|
||||
# 9 as magic bytes was from the cppo script from
|
||||
# https://github.com/RasppleII/a2server but it seems that
|
||||
# more magic bytes might be acceptable?
|
||||
|
||||
#raise InvalidDiskImage("No ProDOS header info found")
|
||||
pass
|
||||
raise UnsupportedDiskImage("ProDOS format found but not supported")
|
||||
|
@ -8,6 +8,18 @@ class InvalidCartHeader(AtrError):
|
||||
pass
|
||||
|
||||
class InvalidDiskImage(AtrError):
|
||||
""" Disk image is not recognized by a parser.
|
||||
|
||||
Usually a signal to try the next parser; this error doesn't propagate out
|
||||
to the user much.
|
||||
"""
|
||||
pass
|
||||
|
||||
class UnsupportedDiskImage(AtrError):
|
||||
""" Disk image is recognized by a parser but it isn't supported yet.
|
||||
|
||||
This error does propagate out to the user.
|
||||
"""
|
||||
pass
|
||||
|
||||
class InvalidDirent(AtrError):
|
||||
|
@ -29,6 +29,8 @@ class SegmentParser(object):
|
||||
self.image = self.get_image(r)
|
||||
self.check_image()
|
||||
self.image.parse_segments()
|
||||
except UnsupportedDiskImage:
|
||||
raise
|
||||
except AtrError, e:
|
||||
raise InvalidSegmentParser(e)
|
||||
self.segments.extend(self.image.segments)
|
||||
|
Loading…
Reference in New Issue
Block a user