forked from ml4tp/gamepad
-
Notifications
You must be signed in to change notification settings - Fork 0
/
chunk.py
41 lines (33 loc) · 1.07 KB
/
chunk.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
import argparse
"""
[Note]
Chunk a build.log by file
python gamepad/chunk.py <path/to/odd-order-build.log> <path/to/chunked>
"""
if __name__ == "__main__":
# Set up command line
argparser = argparse.ArgumentParser()
argparser.add_argument("log", help="Enter the log you want to chunk")
argparser.add_argument("out", help="Location of output")
args = argparser.parse_args()
with open(args.log, 'r') as f:
out = None
while True:
line = f.readline()
if line == "":
print("EOF")
break
elif line.startswith("COQC"):
# close open file if open
if out:
out.close()
# open file for writing
toks = line.split(" ")
v_file = toks[1].strip()
print("COQC", v_file)
out = open("{}/{}.dump".format(args.out, v_file), 'w')
elif out:
# write if file open for writing
out.write(line)
else:
pass