Updated as per Blitzmanns feedback

https://github.com/pyfa-org/Pyfa/pull/639#issuecomment-225749245
This commit is contained in:
Ebag333
2016-06-15 23:42:38 -07:00
parent 47828c38d2
commit 12ccc96f46
3 changed files with 23 additions and 18 deletions

View File

@@ -25,8 +25,8 @@ class ImportError(Exception):
class defaultDatabaseValues():
instance = None
@classmethod
@classmethod
def importDamageProfileDefaults(self):
damageProfileList = []
damageProfileList.append(["Uniform", "25", "25", "25", "25"])
@@ -115,12 +115,14 @@ class defaultDatabaseValues():
damageProfileList.append(["[NPC][Other] Sansha Incursion", "1682", "1347", "3678", "3678"])
for damageProfileRow in damageProfileList:
damageProfile = eos.db.getDamagePattern(damageProfileRow[0])
name, em, therm, kin, exp = damageProfileRow
damageProfile = eos.db.getDamagePattern(name)
if damageProfile is None:
damageProfile = eos.types.DamagePattern(damageProfileRow[1], damageProfileRow[2], damageProfileRow[3], damageProfileRow[4])
damageProfile.name = damageProfileRow[0]
damageProfile = eos.types.DamagePattern(em, therm, kin, exp)
damageProfile.name = name
eos.db.save(damageProfile)
@classmethod
def importResistProfileDefaults(self):
targetResistProfileList = []
targetResistProfileList.append(["Uniform (25%)", "0.25", "0.25", "0.25", "0.25"])
@@ -165,22 +167,24 @@ class defaultDatabaseValues():
targetResistProfileList.append(["[NPC][Burner] Ashimmu (Blood Raiders)", "0.8", "0.76", "0.68", "0.7"])
targetResistProfileList.append(["[NPC][Burner] Talos", "0.68", "0.59", "0.59", "0.43"])
targetResistProfileList.append(["[NPC][Burner] Sentinel", "0.58", "0.45", "0.52", "0.66"])
for targetResistProfileRow in targetResistProfileList:
resistsProfile = eos.db.getTargetResists(targetResistProfileRow[0])
name, em, therm, kin, exp = targetResistProfileRow
resistsProfile = eos.db.eos.db.getTargetResists(name)
if resistsProfile is None:
resistsProfile = eos.types.eos.types.TargetResists(targetResistProfileRow[1], targetResistProfileRow[2], targetResistProfileRow[3], targetResistProfileRow[4])
resistsProfile.name = targetResistProfileRow[0]
resistsProfile = eos.types.TargetResists(em, therm, kin, exp)
resistsProfile.name = name
eos.db.save(resistsProfile)
@classmethod
def importRequiredDefaults(self):
damageProfileList = []
damageProfileList.append(["Uniform", "25", "25", "25", "25"])
for damageProfileRow in damageProfileList:
damageProfile = eos.db.getDamagePattern(damageProfileRow[0])
name, em, therm, kin, exp = damageProfileRow
damageProfile = eos.db.getDamagePattern(name)
if damageProfile is None:
damageProfile = eos.types.DamagePattern(damageProfileRow[1], damageProfileRow[2], damageProfileRow[3],
damageProfileRow[4])
damageProfile.name = damageProfileRow[0]
damageProfile = eos.types.DamagePattern(em, therm, kin, exp)
damageProfile.name = name
eos.db.save(damageProfile)

View File

@@ -36,9 +36,8 @@ class DamagePattern():
def __init__(self):
uniform = eos.db.getDamagePattern("Uniform")
importDBDefaults = loadDefaultDatabaseValues.defaultDatabaseValues()
if uniform is None:
importDBDefaults.importRequiredDefaults()
loadDefaultDatabaseValues.defaultDatabaseValues.importRequiredDefaults()
def getDamagePatternList(self):
return eos.db.getDamagePatternList()

View File

@@ -52,17 +52,19 @@ if os.path.isfile(config.saveDB):
# If database exists, run migration after init'd database
eos.db.saveddata_meta.create_all()
migration.update(eos.db.saveddata_engine)
# Import default database values
# Import values that must exist otherwise Pyfa breaks
loadDefaultDatabaseValues.defaultDatabaseValues.importRequiredDefaults()
else:
# If database does not exist, do not worry about migration. Simply
# create and set version
eos.db.saveddata_meta.create_all()
eos.db.saveddata_engine.execute('PRAGMA user_version = {}'.format(migration.getAppVersion()))
#Import default database values
importDBDefaults = loadDefaultDatabaseValues.defaultDatabaseValues()
#Import values that must exist otherwise Pyfa breaks
importDBDefaults.importRequiredDefaults()
loadDefaultDatabaseValues.defaultDatabaseValues.importRequiredDefaults()
#Import default values for damage profiles
importDBDefaults.importDamageProfileDefaults()
loadDefaultDatabaseValues.defaultDatabaseValues.importDamageProfileDefaults()
#Import default values for target resist profiles
importDBDefaults.importResistProfileDefaults()
loadDefaultDatabaseValues.defaultDatabaseValues.importResistProfileDefaults()