More updates to the script, and data update as well
This commit is contained in:
14
db_update.py
14
db_update.py
@@ -22,6 +22,7 @@
|
||||
import functools
|
||||
import itertools
|
||||
import json
|
||||
import math
|
||||
import os
|
||||
import sqlite3
|
||||
import sys
|
||||
@@ -114,6 +115,12 @@ def update_db():
|
||||
setattr(instance, fieldMap.get(k, k), v)
|
||||
eos.db.gamedata_session.add(instance)
|
||||
|
||||
def _roundToPrec(val, prec):
|
||||
if int(val) == val:
|
||||
return val
|
||||
roundFactor = int(prec - math.floor(math.log10(abs(val))) - 1)
|
||||
return round(val, roundFactor)
|
||||
|
||||
def processEveTypes():
|
||||
print('processing evetypes')
|
||||
data = _readData('fsd_lite', 'evetypes', keyIdName='typeID')
|
||||
@@ -167,11 +174,18 @@ def update_db():
|
||||
data = _readData('fsd_binary', 'typedogma', keyIdName='typeID')
|
||||
eveTypeIds = set(r['typeID'] for r in eveTypesData)
|
||||
newData = []
|
||||
for row in eveTypesData:
|
||||
for attrId, attrName in {4: 'mass', 38: 'capacity', 161: 'volume', 162: 'radius'}.items():
|
||||
if attrName in row:
|
||||
newData.append({'typeID': row['typeID'], 'attributeID': attrId, 'value': row[attrName]})
|
||||
for typeData in data:
|
||||
if typeData['typeID'] not in eveTypeIds:
|
||||
continue
|
||||
for row in typeData.get('dogmaAttributes', ()):
|
||||
row['typeID'] = typeData['typeID']
|
||||
# As of dec 2019, CCP uses single-precision floats in their loader which results
|
||||
# in 'ugly' numbers. Temporarily work around it by rounding here
|
||||
row['value'] = _roundToPrec(row['value'], 7)
|
||||
newData.append(row)
|
||||
_addRows(newData, eos.gamedata.Attribute)
|
||||
return newData
|
||||
|
||||
Reference in New Issue
Block a user