mirror of
https://github.com/robmcmullen/atrcopy.git
synced 2024-11-29 11:51:14 +00:00
Added extra verbosity to show parsing error
This commit is contained in:
parent
7e51284cb1
commit
3a988495e8
@ -78,7 +78,7 @@ def run():
|
||||
for mime in mime_parse_order:
|
||||
if options.verbose:
|
||||
print "Trying MIME type %s" % mime
|
||||
parser = guess_parser_for_mime(mime, rawdata)
|
||||
parser = guess_parser_for_mime(mime, rawdata, options.verbose)
|
||||
if parser is None:
|
||||
continue
|
||||
if options.verbose:
|
||||
|
@ -179,14 +179,14 @@ class AtariDosFile(object):
|
||||
first = False
|
||||
continue
|
||||
elif first:
|
||||
raise InvalidBinaryFile
|
||||
raise InvalidBinaryFile("Object file doesn't start with 0xffff")
|
||||
log.debug("header parsing: header=0x%x" % header)
|
||||
if len(b[pos:pos + 4]) < 4:
|
||||
self.segments.append(ObjSegment(r[pos:pos + 4], 0, 0, 0, len(b[pos:pos + 4]), "Short Segment Header"))
|
||||
break
|
||||
start, end = b[pos:pos + 4].view(dtype='<u2')
|
||||
if end < start:
|
||||
raise InvalidBinaryFile
|
||||
raise InvalidBinaryFile("Nonsensical start and end addresses")
|
||||
count = end - start + 1
|
||||
found = len(b[pos + 4:pos + 4 + count])
|
||||
if found < count:
|
||||
|
@ -10,6 +10,9 @@ from mame import MameZipImage
|
||||
from dos33 import Dos33DiskImage, ProdosDiskImage
|
||||
from errors import *
|
||||
|
||||
import logging
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class SegmentParser(object):
|
||||
menu_name = ""
|
||||
@ -27,8 +30,8 @@ class SegmentParser(object):
|
||||
self.image = self.get_image(r)
|
||||
self.check_image()
|
||||
self.image.parse_segments()
|
||||
except AtrError:
|
||||
raise InvalidSegmentParser
|
||||
except AtrError, e:
|
||||
raise InvalidSegmentParser(e)
|
||||
self.segments.extend(self.image.segments)
|
||||
|
||||
def get_image(self, r):
|
||||
@ -38,8 +41,8 @@ class SegmentParser(object):
|
||||
if self.strict:
|
||||
try:
|
||||
self.image.strict_check()
|
||||
except AtrError:
|
||||
raise InvalidSegmentParser
|
||||
except AtrError, e:
|
||||
raise InvalidSegmentParser(e)
|
||||
else:
|
||||
self.image.relaxed_check()
|
||||
|
||||
@ -101,14 +104,16 @@ class ProdosSegmentParser(SegmentParser):
|
||||
image_type = ProdosDiskImage
|
||||
|
||||
|
||||
def guess_parser_for_mime(mime, r):
|
||||
def guess_parser_for_mime(mime, r, verbose=False):
|
||||
parsers = mime_parsers[mime]
|
||||
found = None
|
||||
for parser in parsers:
|
||||
try:
|
||||
found = parser(r, True)
|
||||
break
|
||||
except InvalidSegmentParser:
|
||||
except InvalidSegmentParser, e:
|
||||
if verbose:
|
||||
log.info("parser isn't %s: %s" % (parser.__name__, str(e)))
|
||||
pass
|
||||
return found
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user