# HG changeset patch # User Henry S. Thompson # Date 1727859397 -3600 # Node ID 96021cfee20960bb15be65bd50ef4528b10baf10 # Parent 51bd09d4289e027043f33f05c7d9e91c9baa5bf6 take bufsize from cmdline diff -r 51bd09d4289e -r 96021cfee209 lib/python/unpackz.py --- a/lib/python/unpackz.py Tue Oct 01 15:59:26 2024 +0100 +++ b/lib/python/unpackz.py Wed Oct 02 09:56:37 2024 +0100 @@ -1,5 +1,7 @@ #!/usr/bin/env python3 -'''See https://stackoverflow.com/a/37042747/2595465''' +'''See https://stackoverflow.com/a/37042747/2595465 +Usage: unpackz.py [-o response-out-file][-b buffer-size] +''' import sys import isal.isal_zlib offset = 0 @@ -9,11 +11,19 @@ outfile = None if sys.argv[1] == '-o': sys.argv.pop(1) - if len(sys.argv)==3: + if len(sys.argv)>=3: outfile = open(sys.argv.pop(1),'wb') else: print('need an outfile', file=sys.stderr) exit(1) +if sys.argv[1] == '-b': + sys.argv.pop(1) + if len(sys.argv)==3: + BUFSIZE = int(sys.argv.pop(1)) + else: + print('need a buffer length', file=sys.stderr) + exit(2) + with open(sys.argv[1],'rb') as f: z = isal.isal_zlib.decompressobj(31) count = 0