change exif.py:main to take multiple paths new-exif
authorTero Marttila <terom@fixme.fi>
Sun, 14 Jun 2009 16:09:04 +0300
branchnew-exif
changeset 107 2e2ef5c99985
parent 106 a4f605bd122c
child 108 f74d8cf678ce
change exif.py:main to take multiple paths
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)
+