File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -266,21 +266,32 @@ class GunzipOutputSpec(TraitedSpec):
266
266
267
267
class Gunzip (BaseInterface ):
268
268
"""Gunzip wrapper
269
+
270
+ >>> from nipype.algorithms.misc import Gunzip
271
+ >>> gunzip = Gunzip(in_file='tpms_msk.nii.gz')
272
+ >>> res = gunzip.run()
273
+ >>> res.outputs.out_file # doctest: +ELLIPSIS
274
+ '.../tpms_msk.nii'
275
+
276
+ .. testcleanup::
277
+
278
+ >>> os.unlink('tpms_msk.nii')
269
279
"""
270
280
input_spec = GunzipInputSpec
271
281
output_spec = GunzipOutputSpec
272
282
273
283
def _gen_output_file_name (self ):
274
284
_ , base , ext = split_filename (self .inputs .in_file )
275
- if ext [- 2 :].lower () == ".gz" :
285
+ if ext [- 3 :].lower () == ".gz" :
276
286
ext = ext [:- 3 ]
277
- return os .path .abspath (base + ext [: - 3 ] )
287
+ return os .path .abspath (base + ext )
278
288
279
289
def _run_interface (self , runtime ):
280
290
import gzip
291
+ import shutil
281
292
with gzip .open (self .inputs .in_file , 'rb' ) as in_file :
282
293
with open (self ._gen_output_file_name (), 'wb' ) as out_file :
283
- out_file . write (in_file . read () )
294
+ shutil . copyfileobj (in_file , out_file )
284
295
return runtime
285
296
286
297
def _list_outputs (self ):
You can’t perform that action at this time.
0 commit comments