diff --git a/CHANGELOG.md b/CHANGELOG.md index 533955e..28ce529 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] - Added GPX parser +- Added optional dry-run modifier ## [0.2] - 2020-02-05 ### Added diff --git a/exif_rad.py b/exif_rad.py index 9f661c6..e9c068f 100755 --- a/exif_rad.py +++ b/exif_rad.py @@ -30,6 +30,8 @@ parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFo them into the Exif tags of given photos.''') parser.add_argument('-si', '--sifactor', type=float, default=0.0065, help='Factor to multiply recorded CPM with.') +parser.add_argument('-d', '--dry', action='store_true', + help='Dry-run, do not actually write anything.') parser.add_argument('csv', metavar='CSV', type=str, help='Geiger counter history file in CSV format.') parser.add_argument('-g', '--gpx', metavar='GPX', type=str, @@ -60,8 +62,13 @@ for srcphoto in args.photos: else: # be os aware and use the correct directory delimiter for destfile dstphoto = os.path.join(args.outdir, photo_basename) - shutil.copy(srcphoto, dstphoto) - photo = dstphoto + print('dry-run:', args.dry) + if args.dry == 'True': + print('Copying file!') + shutil.copy(srcphoto, dstphoto) + photo = dstphoto + else: + photo = srcphoto # Load Exif data from image metadata = pyexiv2.ImageMetadata(photo) @@ -89,7 +96,8 @@ for srcphoto in args.photos: # print found radiation levels print('{:<15} {:<20} {:<22}'.format(photo_basename, str(pictime), new_comment)) # Write Exif tags to file - metadata.write() + if args.dry == 'True': + metadata.write() break else: print('{:<15} {:<20} {:<22}'.format(photo_basename, str(pictime), 'NOT FOUND!')) @@ -97,7 +105,7 @@ for srcphoto in args.photos: f.close() # Import GPX track(s) - if hasattr(args, 'gpx'): + if args.gpx is not None: gpx_file = open(args.gpx, 'r') gpxreader = gpxpy.parse(gpx_file)