# HG changeset patch # User Tero Marttila # Date 1244984944 -10800 # Node ID 2e2ef5c9998572e6aeda482ccde1c08e30446b1f # Parent a4f605bd122c856565a6c84ff93bd7238b338e41 change exif.py:main to take multiple paths diff -r a4f605bd122c -r 2e2ef5c99985 degal/exif.py --- a/degal/exif.py Sat Jun 13 22:22:04 2009 +0300 +++ b/degal/exif.py Sun Jun 14 16:09:04 2009 +0300 @@ -623,30 +623,47 @@ for k, v in exif.get_main_tags().iteritems() : print "%30s: %s" % (k, v) -def main (path, debug=False) : +def main_path (path, dump) : + # dump path + print "%s: " % path + + # try and load it + exif = load_path(path) + + if not exif : + raise Exception("No EXIF data found") + + if dump : + # dump everything + dump_exif(exif) + + else : + # list them + list_tags(exif) + + +def main (paths, dump=False) : """ Load and dump EXIF data from the given path """ - # try and load it - exif = load_path(path) - - if not exif : - raise Exception("No EXIF data found") - - if debug : - # dump it - print "%s: " % path - print - - dump_exif(exif) - - else : - # list them - list_tags(exif) + # handle each one + for path in paths : + main_path(path, dump=dump) if __name__ == '__main__' : + import getopt from sys import argv + + # defaults + dump = False - main(argv[1], '-d' in argv) + # parse args + opts, args = getopt.getopt(argv[1:], "d", ["dump"]) + for opt, val in opts : + if opt in ('-d', "--dump") : + dump = True + + main(args, dump=dump) +