@@ -442,6 +442,10 @@ def _argument_parser():
442
442
help = "write on standard output" )
443
443
output_group .add_argument ("-o" , "--output" ,
444
444
help = "Write to this output file" )
445
+ parser .add_argument ("-n" , "--no-name" , action = "store_true" ,
446
+ dest = "reproducible" ,
447
+ help = "do not save or restore the original name and "
448
+ "timestamp" )
445
449
parser .add_argument ("-f" , "--force" , action = "store_true" ,
446
450
help = "Overwrite output without prompting" )
447
451
# -b flag not taken by either gzip or igzip. Hidden attribute. Above 32K
@@ -485,10 +489,16 @@ def main():
485
489
else :
486
490
in_file = io .open (args .file , mode = "rb" )
487
491
if out_filepath is not None :
488
- out_file = open (out_filepath , "wb" , compresslevel = compresslevel )
492
+ out_buffer = io . open (out_filepath , "wb" )
489
493
else :
490
- out_file = IGzipFile (mode = "wb" , fileobj = sys .stdout .buffer ,
491
- compresslevel = compresslevel )
494
+ out_buffer = sys .stdout .buffer
495
+
496
+ if args .reproducible :
497
+ gzip_file_kwargs = {"mtime" : 0 , "filename" : b"" }
498
+ else :
499
+ gzip_file_kwargs = {"filename" : out_filepath }
500
+ out_file = IGzipFile (mode = "wb" , fileobj = out_buffer ,
501
+ compresslevel = compresslevel , ** gzip_file_kwargs )
492
502
else :
493
503
if args .file :
494
504
in_file = open (args .file , mode = "rb" )
0 commit comments