changeset 241:96021cfee209

take bufsize from cmdline
author Henry S. Thompson <ht@inf.ed.ac.uk>
date Wed, 02 Oct 2024 09:56:37 +0100
parents 51bd09d4289e
children e117424e244a
files lib/python/unpackz.py
diffstat 1 files changed, 12 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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