-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathShipIndex.py
34 lines (28 loc) · 1.08 KB
/
ShipIndex.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
# -*- coding: utf-8 -*-
import re, os
import util
def getShipGroup():
return util.parseDataFile('ship_data_group')
def getShipStatistics():
return util.parseDataFile('ship_data_statistics')
def getShipTemplate():
return util.parseDataFile('ship_data_template')
def getShipName(groupID, shipStatistics, shipTemplate):
for k, v in shipTemplate.items():
if v['group_type'] == groupID:
for i, j in shipStatistics.items():
if j['id'] == v['id']:
return j['name']
def createNameList():
shipGroup = getShipGroup()
shipStatistics = getShipStatistics()
shipTemplate = getShipTemplate()
shipCollection = {}
for k, v in shipGroup.items():
shipCollection[v['code']] = v['group_type']
with open(os.path.join(util.WikiDirectory, 'nameIndex.txt'), 'w+', encoding='utf-8') as f:
for k, v in shipCollection.items():
name = getShipName(v, shipStatistics, shipTemplate)
f.write(name + ', ' + str(k) + ', ' + str(v) + '\n')
if __name__ == "__main__":
createNameList()