Mercurial > hg > cc > cirrus_home
changeset 99:d48537c4cbae
triple args checked, filename opened
author | Henry S. Thompson <ht@inf.ed.ac.uk> |
---|---|
date | Fri, 16 Apr 2021 18:28:00 +0000 |
parents | 1a4c5fdc2923 |
children | f7623dbd8eb5 |
files | bin/ix.py |
diffstat | 1 files changed, 8 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- 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)