diff --git a/src/greaseweazle/tools/convert.py b/src/greaseweazle/tools/convert.py index 2b5df8b..8788470 100644 --- a/src/greaseweazle/tools/convert.py +++ b/src/greaseweazle/tools/convert.py @@ -18,6 +18,7 @@ from greaseweazle.codec import codec from greaseweazle.track import MasterTrack from greaseweazle.image.image import Image +from greaseweazle.image.img import IMG from greaseweazle import track plls = track.plls @@ -171,6 +172,10 @@ def main(argv) -> None: Known formats:\n%s""" % (args.format, codec.print_formats( args.diskdefs))) + in_image = open_input_image(args, in_image_class) + if args.fmt_cls is None and isinstance(in_image, IMG): + args.fmt_cls = in_image.fmt + if args.fmt_cls is not None: def_tracks = copy.copy(args.fmt_cls.tracks) if def_tracks is None: def_tracks = util.TrackSet('c=0-81:h=0-1') @@ -184,11 +189,10 @@ def main(argv) -> None: out_def_tracks.update_from_trackspec(args.out_tracks.trackspec) args.out_tracks = out_def_tracks - print("Converting %s -> %s" % (args.tracks, args.out_tracks)) if args.format: print("Format " + args.format) + print("Converting %s -> %s" % (args.tracks, args.out_tracks)) - in_image = open_input_image(args, in_image_class) with open_output_image(args, out_image_class) as out_image: convert(args, in_image, out_image) diff --git a/src/greaseweazle/tools/write.py b/src/greaseweazle/tools/write.py index a9916de..3db1340 100644 --- a/src/greaseweazle/tools/write.py +++ b/src/greaseweazle/tools/write.py @@ -18,6 +18,7 @@ from greaseweazle import usb as USB from greaseweazle.codec import codec from greaseweazle.image import image +from greaseweazle.image.img import IMG from greaseweazle.track import HasVerify, MasterTrack # Read and parse the image file. @@ -266,6 +267,10 @@ def main(argv) -> None: Known formats:\n%s""" % (args.format, codec.print_formats( args.diskdefs))) + image = open_image(args, image_class) + if args.fmt_cls is None and isinstance(image, IMG): + args.fmt_cls = image.fmt + if args.fmt_cls is not None: def_tracks = copy.copy(args.fmt_cls.tracks) if def_tracks is None: def_tracks = util.TrackSet('c=0-81:h=0-1') @@ -273,12 +278,11 @@ def main(argv) -> None: def_tracks.update_from_trackspec(args.tracks.trackspec) args.tracks = def_tracks usb = util.usb_open(args.device) - image = open_image(args, image_class) + if args.format: + print("Format " + args.format) print("Writing " + str(args.tracks)) if args.precomp is not None: print(args.precomp) - if args.format: - print("Format " + args.format) try: if args.densel is not None or args.gen_tg43: prev_pin2 = usb.get_pin(2)