-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathmake_gptt_patch.py
More file actions
65 lines (59 loc) · 1.51 KB
/
make_gptt_patch.py
File metadata and controls
65 lines (59 loc) · 1.51 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
fout = []
fin = open('GPTT_yonge.cfg', 'r')
outf = open('zzzGPTT_base_parts.cfg', 'w')
parts = ''
start = True
tech = ''
sp = False
for line in fin:
if ('id = ') in line:
if start:
start = False
else:
if len(parts) > 1:
newline = '@PART['
newline += parts
outf.writelines([
newline[:-1] + ']:LAST[zzGPTT]\n',
'{\n',
' @TechRequired = ' + tech,
'}\n',
])
tech = ''
parts = ''
ch = ''
for c in line:
if 'id = ' in ch:
tech += c
else:
ch += c
print(tech)
elif (' part = ') in line:
ch = ''
part = ''
sp = False
for c in line:
if 'part = ' in ch:
if c == '/':
part += c
break
elif c == ' ':
sp = True
else:
if sp:
part += '?'
sp = False
part += c
else:
ch += c
parts+=part[:-1]+'|'
if len(parts) > 1:
newline = '@PART['
newline += parts
outf.writelines([
newline[:-1] + ']:LAST[zzGPTT]\n',
'{\n',
' @TechRequired = ' + tech,
'}\n',
])
outf.close()