|
43 | 43 | ``True``, ``False``, or ``'auto'``. |
44 | 44 |
|
45 | 45 | If ``True``, a single file handle is created and used. If ``False``, a new |
46 | | -file handle is created every time the image is accessed. If ``'auto'``, and |
47 | | -the optional ``indexed_gzip`` dependency is present, a single file handle is |
48 | | -created and persisted. If ``indexed_gzip`` is not available, behaviour is the |
49 | | -same as if ``keep_file_open is False``. |
| 46 | +file handle is created every time the image is accessed. For gzip files, if |
| 47 | +``'auto'``, and the optional ``indexed_gzip`` dependency is present, a single |
| 48 | +file handle is created and persisted. If ``indexed_gzip`` is not available, |
| 49 | +behaviour is the same as if ``keep_file_open is False``. |
50 | 50 |
|
51 | 51 | If this is set to any other value, attempts to create an ``ArrayProxy`` without |
52 | 52 | specifying the ``keep_file_open`` flag will result in a ``ValueError`` being |
@@ -186,7 +186,7 @@ def _should_keep_file_open(self, file_like, keep_file_open): |
186 | 186 | The return value is derived from these rules: |
187 | 187 |
|
188 | 188 | - If ``file_like`` is a file(-like) object, ``False`` is returned. |
189 | | - Otherwise, ``file_like`` is assumed to be a file name |
| 189 | + Otherwise, ``file_like`` is assumed to be a file name. |
190 | 190 | - If ``keep_file_open`` is ``auto``, and ``indexed_gzip`` is |
191 | 191 | not available, ``False`` is returned. |
192 | 192 | - Otherwise, the value of ``keep_file_open`` is returned unchanged. |
@@ -214,7 +214,8 @@ def _should_keep_file_open(self, file_like, keep_file_open): |
214 | 214 | if hasattr(file_like, 'read') and hasattr(file_like, 'seek'): |
215 | 215 | return False |
216 | 216 | # don't have indexed_gzip - auto -> False |
217 | | - if keep_file_open == 'auto' and not HAVE_INDEXED_GZIP: |
| 217 | + if keep_file_open == 'auto' and not (HAVE_INDEXED_GZIP and |
| 218 | + file_like.endswith('.gz')): |
218 | 219 | return False |
219 | 220 | return keep_file_open |
220 | 221 |
|
@@ -260,7 +261,7 @@ def _get_fileobj(self): |
260 | 261 | A newly created ``ImageOpener`` instance, or an existing one, |
261 | 262 | which provides access to the file. |
262 | 263 | """ |
263 | | - if bool(self._keep_file_open): |
| 264 | + if self._keep_file_open: |
264 | 265 | if not hasattr(self, '_opener'): |
265 | 266 | self._opener = ImageOpener( |
266 | 267 | self.file_like, keep_open=self._keep_file_open) |
|
0 commit comments