]> git.decadent.org.uk Git - dak.git/commitdiff
wrap try..except..finally the python 2.4 way
authorPhilipp Kern <pkern@debian.org>
Sun, 7 Sep 2008 19:48:53 +0000 (19:48 +0000)
committerPhilipp Kern <pkern@debian.org>
Sun, 7 Sep 2008 19:48:53 +0000 (19:48 +0000)
2008-09-07  Philipp Kern  <pkern@debian.org>

        * daklib/utils.py (check_hash): try..except..finally only
        works on python >=2.5.

Signed-off-by: Philipp Kern <pkern@debian.org>
ChangeLog
daklib/utils.py

index a5469a1af86c44ff3abed82e4994c388a8bb67fa..140b1dfd154f1864e28f311a1659a81f8a9ad85a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2008-09-07  Philipp Kern  <pkern@debian.org>
+
+       * daklib/utils.py (check_hash): try..except..finally only
+       works on python >=2.5.
+
 2008-09-07  Philipp Kern  <pkern@debian.org>
 
        * daklib/utils.py (check_hash): change the comment and warn
index 8e06cf35cc6dbbc795b008865c64991b2d9dbfc3..03135e72e4a58fe99dc9ad05c8506c707957d55f 100755 (executable)
@@ -252,22 +252,23 @@ def check_hash(where, files, hashname, hashfunc):
     for f in files.keys():
         file_handle = None
         try:
-            file_handle = open_file(f)
-
-            # Check for the hash entry, to not trigger a KeyError.
-            if not files[f].has_key(hash_key(hashname)):
-                rejmsg.append("%s: misses %s checksum in %s" % (f, hashname,
-                    where))
+            try:
+                file_handle = open_file(f)
+    
+                # Check for the hash entry, to not trigger a KeyError.
+                if not files[f].has_key(hash_key(hashname)):
+                    rejmsg.append("%s: misses %s checksum in %s" % (f, hashname,
+                        where))
+                    continue
+    
+                # Actually check the hash for correctness.
+                if hashfunc(file_handle) != files[f][hash_key(hashname)]:
+                    rejmsg.append("%s: %s check failed in %s" % (f, hashname,
+                        where))
+            except CantOpenError:
+                # TODO: This happens when the file is in the pool.
+                warn("Cannot open file %s" % f)
                 continue
-
-            # Actually check the hash for correctness.
-            if hashfunc(file_handle) != files[f][hash_key(hashname)]:
-                rejmsg.append("%s: %s check failed in %s" % (f, hashname,
-                    where))
-        except CantOpenError:
-            # TODO: This happens when the file is in the pool.
-            warn("Cannot open file %s" % f)
-            continue
         finally:
             if file_handle:
                 file_handle.close()