Use `with Closing(...) as f:` in JPKDriver._zip_segment().
authorW. Trevor King <wking@drexel.edu>
Thu, 9 Sep 2010 12:26:49 +0000 (08:26 -0400)
committerW. Trevor King <wking@drexel.edu>
Thu, 9 Sep 2010 12:26:49 +0000 (08:26 -0400)
hooke/driver/jpk.py

index 6fe84f01d3860e7b0df45a8b0e212448168ce228..f9ba0fdb454fa64724dadb490e3335bf4689b1aa 100644 (file)
@@ -113,10 +113,10 @@ class JPKDriver (Driver):
             return info
 
     def _zip_segment(self, zipfile, path, info, zip_info, index, version):
-        prop_file = zipfile.open(os.path.join(
-                'segments', str(index), 'segment-header.properties'))
-        prop = self._parse_params(prop_file.readlines())
-        prop_file.close()
+        with Closing(zipfile.open(os.path.join(
+                    'segments', str(index), 'segment-header.properties'))
+                     ) as f:
+            prop = self._parse_params(f.readlines())
         expected_shape = (int(prop['force-segment-header']['num-points']),)
         channels = []
         if 'list' not in prop['channels']: