@@ -273,6 +273,7 @@ def _list_outputs(self):
273
273
274
274
class GunzipInputSpec (BaseInterfaceInputSpec ):
275
275
in_file = File (exists = True , mandatory = True )
276
+ compress = traits .Bool (default_value = False )
276
277
277
278
278
279
class GunzipOutputSpec (TraitedSpec ):
@@ -298,17 +299,28 @@ class Gunzip(BaseInterface):
298
299
299
300
def _gen_output_file_name (self ):
300
301
_ , base , ext = split_filename (self .inputs .in_file )
301
- if ext [- 3 :].lower () == ".gz" :
302
- ext = ext [:- 3 ]
302
+
303
+ if self .inputs .compress :
304
+ ext += ".gz"
305
+ else :
306
+ if ext [- 3 :].lower () == ".gz" :
307
+ ext = ext [:- 3 ]
308
+
303
309
return os .path .abspath (base + ext )
304
310
305
311
def _run_interface (self , runtime ):
306
312
import gzip
307
313
import shutil
308
314
309
- with gzip .open (self .inputs .in_file , "rb" ) as in_file :
310
- with open (self ._gen_output_file_name (), "wb" ) as out_file :
311
- shutil .copyfileobj (in_file , out_file )
315
+ if self .inputs .compress :
316
+ with open (self .inputs .in_file , "rb" ) as in_file :
317
+ with gzip .open (self ._gen_output_file_name (), "wb" ) as out_file :
318
+ shutil .copyfileobj (in_file , out_file )
319
+ else :
320
+ with gzip .open (self .inputs .in_file , "rb" ) as in_file :
321
+ with open (self ._gen_output_file_name (), "wb" ) as out_file :
322
+ shutil .copyfileobj (in_file , out_file )
323
+
312
324
return runtime
313
325
314
326
def _list_outputs (self ):
0 commit comments