Skip to content

Commit ec3ee12

Browse files
committed
Enable --no-name flag on python -m isal.igzip
1 parent 4cd7fe3 commit ec3ee12

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/isal/igzip.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,10 @@ def _argument_parser():
442442
help="write on standard output")
443443
output_group.add_argument("-o", "--output",
444444
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")
445449
parser.add_argument("-f", "--force", action="store_true",
446450
help="Overwrite output without prompting")
447451
# -b flag not taken by either gzip or igzip. Hidden attribute. Above 32K
@@ -485,10 +489,16 @@ def main():
485489
else:
486490
in_file = io.open(args.file, mode="rb")
487491
if out_filepath is not None:
488-
out_file = open(out_filepath, "wb", compresslevel=compresslevel)
492+
out_buffer = io.open(out_filepath, "wb")
489493
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)
492502
else:
493503
if args.file:
494504
in_file = open(args.file, mode="rb")

0 commit comments

Comments
 (0)