Moved main script into run() function

This commit is contained in:
Rob McMullen 2016-02-09 10:32:02 -08:00
parent 7b3c009e63
commit 59d5f40e10

View File

@ -776,7 +776,7 @@ def process(image, dirent, options):
else: else:
print dirent print dirent
if __name__ == "__main__": def run():
import sys import sys
import argparse import argparse
@ -800,8 +800,8 @@ if __name__ == "__main__":
data = to_numpy(data) data = to_numpy(data)
try: try:
header = AtrHeader(data[0:16]) header = AtrHeader(data[0:16])
for format in [KBootImage, AtariDosDiskImage, BootDiskImage]: for format in [KBootImage, AtariDosDiskImage]:
print "trying", format.__name__ if options.verbose: print "trying", format.__name__
try: try:
image = format(data, filename) image = format(data, filename)
print "%s: %s" % (filename, image) print "%s: %s" % (filename, image)
@ -818,12 +818,11 @@ if __name__ == "__main__":
raise raise
#pass #pass
except: except:
raise if options.verbose: print "%s: Doesn't look like a supported disk image" % filename
print "%s: Doesn't look like a supported disk image" % filename
try: try:
image = AtariDosFile(data, filename) image = AtariDosFile(data)
except InvalidBinaryFile: except InvalidBinaryFile:
print "%s: Doesn't look like an XEX either" % filename if options.verbose: print "%s: Doesn't look like an XEX either" % filename
continue continue
if image is None: if image is None:
image = BootDiskImage(data, filename) image = BootDiskImage(data, filename)
@ -839,3 +838,5 @@ if __name__ == "__main__":
except ByteNotInFile166: except ByteNotInFile166:
print "Invalid sector for: %s" % str(dirent) print "Invalid sector for: %s" % str(dirent)
if __name__ == "__main__":
run()