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):
266266
267267class Gunzip (BaseInterface ):
268268 """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')
269279 """
270280 input_spec = GunzipInputSpec
271281 output_spec = GunzipOutputSpec
272282
273283 def _gen_output_file_name (self ):
274284 _ , base , ext = split_filename (self .inputs .in_file )
275- if ext [- 2 :].lower () == ".gz" :
285+ if ext [- 3 :].lower () == ".gz" :
276286 ext = ext [:- 3 ]
277- return os .path .abspath (base + ext [: - 3 ] )
287+ return os .path .abspath (base + ext )
278288
279289 def _run_interface (self , runtime ):
280290 import gzip
291+ import shutil
281292 with gzip .open (self .inputs .in_file , 'rb' ) as in_file :
282293 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 )
284295 return runtime
285296
286297 def _list_outputs (self ):
You can’t perform that action at this time.
0 commit comments