From f217f17dab4c62aba4dbdd3adfcd69b6c9d7135a Mon Sep 17 00:00:00 2001 From: Rob McMullen Date: Sat, 9 May 2015 10:01:59 -0700 Subject: [PATCH] Added command line arguments to atrdump * added execute persmissions --- atrcopy.py | 0 atrdump.py | 39 +++++++++++++++++++++++++++++++++------ 2 files changed, 33 insertions(+), 6 deletions(-) mode change 100644 => 100755 atrcopy.py mode change 100644 => 100755 atrdump.py diff --git a/atrcopy.py b/atrcopy.py old mode 100644 new mode 100755 diff --git a/atrdump.py b/atrdump.py old mode 100644 new mode 100755 index aba757c..9b4bfdf --- a/atrdump.py +++ b/atrdump.py @@ -2,17 +2,44 @@ from atrutil import * +def process(dirent, options): + skip = options.dry_run + why = "Copying" + filename = dirent.get_filename() + outfilename = filename + if options.games: + if dirent.ext == "SYS": + skip = True + why = "System file skipped" + if not skip: + if options.xex: + outfilename = "%s%s.XEX" % (dirent.filename, dirent.ext) + why = "Copying to %s" % outfilename + bytes = atr.get_file(dirent) + with open(outfilename, "wb") as fh: + fh.write(bytes) + print "%s: %s" % (filename, why) + if __name__ == "__main__": import sys + import argparse - for args in sys.argv: + parser = argparse.ArgumentParser(description="Extract images off ATR format disks") + parser.add_argument("-v", "--verbose", default=0, action="count") + parser.add_argument("--dry-run", action="store_true", default=False, help="Don't extract, just show what would have been extracted") + parser.add_argument("-g", "--games", action="store_true", default=False, help="Only extract things that look like games (no DOS or .SYS files)") + parser.add_argument("-x", "--xex", action="store_true", default=False, help="Add .xex extension") + options, extra_args = parser.parse_known_args() + + for args in extra_args: print args with open(args, "rb") as fh: atr = AtrDiskImage(fh) - print atr + if options.verbose: + print atr for dirent in atr.files: - bytes = atr.get_file(dirent) - filename = dirent.get_filename() - with open(filename, "wb") as fh: - fh.write(bytes) + try: + process(dirent, options) + except FileNumberMismatchError164: + print "Error 164: %s" % str(dirent)