From 979fe73c60f312414feebf9f50fbaffca1b071a1 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Thu, 9 Sep 2010 08:26:49 -0400 Subject: [PATCH] Use `with Closing(...) as f:` in JPKDriver._zip_segment(). --- hooke/driver/jpk.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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']: -- 2.26.2