From: W. Trevor King Date: Thu, 9 Sep 2010 12:26:49 +0000 (-0400) Subject: Use `with Closing(...) as f:` in JPKDriver._zip_segment(). X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=979fe73c60f312414feebf9f50fbaffca1b071a1;p=hooke.git Use `with Closing(...) as f:` in JPKDriver._zip_segment(). --- diff --git a/hooke/driver/jpk.py b/hooke/driver/jpk.py index 6fe84f0..f9ba0fd 100644 --- a/hooke/driver/jpk.py +++ b/hooke/driver/jpk.py @@ -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']: