Mercurial > hg > cc > cirrus_home
comparison bin/nogood.py @ 52:9cd9daf75183
working towards more robust diff checking
author | Henry S. Thompson <ht@inf.ed.ac.uk> |
---|---|
date | Mon, 13 Apr 2020 14:12:12 +0100 |
parents | |
children | 396d1f17c671 |
comparison
equal
deleted
inserted
replaced
51:427056f1784e | 52:9cd9daf75183 |
---|---|
1 #!/lustre/sw/miniconda3/bin/python3 | |
2 '''Detect bad diffs between warc.sh log file and existing extract_...tar | |
3 Usage: nogood.py segid numChanged | |
4 Note the slightly counter-intuitive value: 0 if the input is no good''' | |
5 import sys,re | |
6 LONG_ADD=re.compile('[1-9][0-9]*a[1-9][0-9]*,[1-9][0-9]*') | |
7 (segment,n)=map(int,sys.argv[1:]) | |
8 c=0 | |
9 for l in sys.stdin: | |
10 (i,d)=l.rstrip().split(':') | |
11 if LONG_ADD.fullmatch(d): | |
12 c+=1 | |
13 continue | |
14 else: | |
15 print("non-simple diff at %s: %s for segment %s"%(i,d,segment),file=sys.stderr) | |
16 exit(0) | |
17 if c!=n: | |
18 print("too many diffs? (%s<>%s) for segment %s"%(c,n,segment),file=sys.stderr) | |
19 exit(0) | |
20 exit(1) |