-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathkv7planning-index.py
50 lines (37 loc) · 1.17 KB
/
kv7planning-index.py
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
40
41
42
43
44
45
46
47
48
49
50
from gzip import GzipFile
import sys
import os
import codecs
table = None
dumping = False
knownfiles = set([])
try:
with codecs.open('kv7planning.idx', 'r', 'UTF-8') as output:
old = output.read()
for x in old.split('\n'):
knownfiles.add(sys.argv[1] + '/' + x.split('|')[-1])
except:
old = ''
files = []
for dirs in sys.argv[1:]:
files += [dirs + '/' + x for x in os.listdir(dirs)]
files = set(files) - (knownfiles)
output = codecs.open('kv7planning.idx', 'w', 'UTF-8')
output.write(old)
for filename in sorted(files):
localservicelevelcodes = set([])
for line in GzipFile(filename, 'r'):
if line[0] == '\\':
if dumping:
dumping = False
if table == 'LOCALSERVICEGROUPPASSTIME' and line[1] == 'L':
dumping = True
elif line[1] == 'T':
table = line[2:].split('|')[0]
else:
if dumping:
line = line.decode('UTF-8').split('|')
localservicelevelcodes.add(line[0] + "|" + line[1])
for x in localservicelevelcodes:
output.write(x + "|" + os.path.basename(filename) + '\n')
output.close()