-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcoverage.py
More file actions
44 lines (31 loc) · 995 Bytes
/
Copy pathcoverage.py
File metadata and controls
44 lines (31 loc) · 995 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import gzip
import sys
import locale
locale.setlocale(locale.LC_ALL,"")
big_name = sys.argv[1]
small_name = sys.argv[2]
count = 0
with gzip.open(big_name, "rb") as big, gzip.open(small_name, "rb") as small:
next_target = small.readline().strip()
curr = big.readline().strip()
while True:
#c = cmp(curr, next_target)
if curr == next_target:
c = 0
else:
s = sorted([curr, next_target], cmp=locale.strcoll)
c = -1 if s[0] == curr else 1
#print c, curr, " ", next_target
if c > 0:
next_target = small.readline().strip()
if not next_target:
break
elif c==0:
count += 1
next_target = small.readline().strip()
if not next_target:
break
else:
curr = big.readline().strip()
with open(big_name + ".result", "w") as outfile:
outfile.write(str(count))