Mercurial > hg > cc > cirrus_work
view bin/test_warc.py @ 65:b88fdbe8bfa7
add a response-only test
author | Henry S. Thompson <ht@inf.ed.ac.uk> |
---|---|
date | Wed, 19 Jul 2023 13:19:58 +0100 |
parents | 9837840f3328 |
children |
line wrap: on
line source
import warc,sys OUT=open(sys.stdout.fileno(),'wb') if (debug:=(sys.argv[1]=='-d')): sys.argv.pop(1) tt=int(sys.argv.pop(1)) def showme(wtype,buf,part): # This should exactly reproduce a complete warc file if called # as per version 1 below if debug: OUT.write(b"----start %d-----\n"%part) OUT.write(buf) if buf[-1]!=10: OUT.write(b'\r\n') if part==7: OUT.write(b'\r\n') # to match complete file formatting if debug: OUT.write(b"----end %d-----\n"%part) return OUT if tt==1: warc.warc(sys.argv[1],showme,[b'response','warcinfo','request','metadata'],parts=int(sys.argv[2]),debug=debug) elif tt==2: warc.warc(sys.argv[1],showme,[b'warcinfo'],parts=int(sys.argv[2]),debug=debug) elif tt==3: warc.warc(sys.argv[1],showme,[b'warcinfo'],whole=True,debug=debug) elif tt==4: warc.warc(sys.argv[1],showme,[b'response','warcinfo','request','metadata'],whole=True,debug=debug) elif tt==5: warc.warc(sys.argv[1],showme,[b'response'],parts=int(sys.argv[2]),debug=debug)