# HG changeset patch # User Henry S. Thompson # Date 1618597680 0 # Node ID d48537c4cbae45a9e98ae735ddd3ba28edac3818 # Parent 1a4c5fdc29238af65c44b964d9ed798af6e47181 triple args checked, filename opened diff -r 1a4c5fdc2923 -r d48537c4cbae bin/ix.py --- a/bin/ix.py Fri Apr 16 13:15:23 2021 +0000 +++ b/bin/ix.py Fri Apr 16 18:28:00 2021 +0000 @@ -52,11 +52,17 @@ nargs='?') parser.add_argument('filename', help='name of gzipped Common Crawl WARC-format file', - nargs='?') + nargs='?', + type=argparse.FileType('rb',0)) # Hack the order of optional and positional in the help output parser._action_groups.sort(key=lambda g:g.title) #parser.print_help() pa=parser.parse_args(sys.argv[1:]) # We have to enforce our own check.. -print(pa) +print(pa,file=sys.stderr) +if pa.length is not None and ( + pa.offset is None or pa.filename is None): + parser.error("length, offset and filename must all be supplied together") + +buf=bytearray(1024*1024)