Merge pull request #639 from Ebag333/default-database-profiles
Default database profiles
This commit is contained in:
@@ -23,10 +23,10 @@ import eos.types
|
||||
class ImportError(Exception):
|
||||
pass
|
||||
|
||||
class defaultDatabaseValues():
|
||||
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)
|
||||
|
||||
@@ -6,5 +6,13 @@ type = "active"
|
||||
def handler(fit, module, context):
|
||||
for type in ("kinetic", "thermal", "explosive", "em"):
|
||||
attr = "armor%sDamageResonance" % type.capitalize()
|
||||
|
||||
#Adjust RAH to match the current damage pattern
|
||||
damagePattern = fit.damagePattern
|
||||
attrDamagePattern = "%sAmount" % type
|
||||
damagePatternModifier = getattr(damagePattern,attrDamagePattern)/float(sum((damagePattern.emAmount,damagePattern.thermalAmount,damagePattern.kineticAmount,damagePattern.explosiveAmount)))
|
||||
modifiedResistModifier = (1-(((1-module.getModifiedItemAttr(attr))*4)*(damagePatternModifier)))
|
||||
module.forceItemAttr(attr, modifiedResistModifier)
|
||||
|
||||
fit.ship.multiplyItemAttr(attr, module.getModifiedItemAttr(attr),
|
||||
stackingPenalties=True, penaltyGroup="preMul")
|
||||
|
||||
@@ -38,7 +38,6 @@ import gui.aboutData
|
||||
import gui.chromeTabs
|
||||
import gui.utils.animUtils as animUtils
|
||||
import gui.globalEvents as GE
|
||||
import eos.db.saveddata.loadDefaultDatabaseValues as loadDefaultDatabaseValues
|
||||
|
||||
from gui.bitmapLoader import BitmapLoader
|
||||
from gui.mainMenuBar import MainMenuBar
|
||||
@@ -62,6 +61,7 @@ from gui.builtinViews import *
|
||||
|
||||
# import this to access override setting
|
||||
from eos.modifiedAttributeDict import ModifiedAttributeDict
|
||||
from eos.db.saveddata.loadDefaultDatabaseValues import DefaultDatabaseValues
|
||||
|
||||
from time import gmtime, strftime
|
||||
|
||||
@@ -407,14 +407,12 @@ class MainFrame(wx.Frame):
|
||||
webbrowser.open('https://forums.eveonline.com/default.aspx?g=posts&t=466425')
|
||||
|
||||
def loadDatabaseDefaults(self, event):
|
||||
# Import default database values
|
||||
importDBDefaults = loadDefaultDatabaseValues.defaultDatabaseValues()
|
||||
# Import values that must exist otherwise Pyfa breaks
|
||||
importDBDefaults.importRequiredDefaults()
|
||||
DefaultDatabaseValues.importRequiredDefaults()
|
||||
# Import default values for damage profiles
|
||||
importDBDefaults.importDamageProfileDefaults()
|
||||
DefaultDatabaseValues.importDamageProfileDefaults()
|
||||
# Import default values for target resist profiles
|
||||
importDBDefaults.importResistProfileDefaults()
|
||||
DefaultDatabaseValues.importResistProfileDefaults()
|
||||
|
||||
def registerMenu(self):
|
||||
menuBar = self.GetMenuBar()
|
||||
|
||||
@@ -148,6 +148,8 @@ class MainMenuBar(wx.MenuBar):
|
||||
helpMenu.Append(self.wikiId, "Wiki", "Go to wiki on GitHub")
|
||||
helpMenu.Append(self.forumId, "Forums", "Go to EVE Online Forum thread")
|
||||
helpMenu.AppendSeparator()
|
||||
helpMenu.Append(self.importDatabaseDefaultsId, "Import D&atabase Defaults", "Imports missing database defaults")
|
||||
helpMenu.AppendSeparator()
|
||||
helpMenu.Append(wx.ID_ABOUT)
|
||||
|
||||
if config.debug:
|
||||
|
||||
@@ -19,9 +19,10 @@
|
||||
|
||||
import eos.db
|
||||
import eos.types
|
||||
import eos.db.saveddata.loadDefaultDatabaseValues as loadDefaultDatabaseValues
|
||||
import copy
|
||||
|
||||
from eos.db.saveddata.loadDefaultDatabaseValues import DefaultDatabaseValues
|
||||
|
||||
class ImportError(Exception):
|
||||
pass
|
||||
|
||||
@@ -34,12 +35,6 @@ class DamagePattern():
|
||||
|
||||
return cls.instance
|
||||
|
||||
def __init__(self):
|
||||
uniform = eos.db.getDamagePattern("Uniform")
|
||||
importDBDefaults = loadDefaultDatabaseValues.defaultDatabaseValues()
|
||||
if uniform is None:
|
||||
importDBDefaults.importRequiredDefaults()
|
||||
|
||||
def getDamagePatternList(self):
|
||||
return eos.db.getDamagePatternList()
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#===============================================================================
|
||||
# ===============================================================================
|
||||
# Copyright (C) 2010 Diego Duclos
|
||||
#
|
||||
# This file is part of pyfa.
|
||||
@@ -15,7 +15,7 @@
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
|
||||
#===============================================================================
|
||||
# ===============================================================================
|
||||
|
||||
import locale
|
||||
import copy
|
||||
@@ -40,6 +40,7 @@ from service.port import Port
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class FitBackupThread(threading.Thread):
|
||||
def __init__(self, path, callback):
|
||||
threading.Thread.__init__(self)
|
||||
@@ -257,7 +258,7 @@ class Fit(object):
|
||||
|
||||
if not projected:
|
||||
for fitP in fit.projectedFits:
|
||||
self.getFit(fitP.ID, projected = True)
|
||||
self.getFit(fitP.ID, projected=True)
|
||||
self.recalc(fit, withBoosters=True)
|
||||
fit.fill()
|
||||
|
||||
@@ -413,7 +414,7 @@ class Fit(object):
|
||||
def changeActiveFighters(self, fitID, fighter, amount):
|
||||
fit = eos.db.getFit(fitID)
|
||||
fighter.amountActive = amount
|
||||
|
||||
|
||||
eos.db.commit()
|
||||
self.recalc(fit)
|
||||
|
||||
@@ -427,7 +428,7 @@ class Fit(object):
|
||||
fit.projectedFighters.remove(thing)
|
||||
else:
|
||||
del fit.__projectedFits[thing.ID]
|
||||
#fit.projectedFits.remove(thing)
|
||||
# fit.projectedFits.remove(thing)
|
||||
|
||||
eos.db.commit()
|
||||
self.recalc(fit)
|
||||
@@ -943,7 +944,7 @@ class Fit(object):
|
||||
fits = []
|
||||
for path in paths:
|
||||
if callback: # Pulse
|
||||
wx.CallAfter(callback, 1, "Processing file:\n%s"%path)
|
||||
wx.CallAfter(callback, 1, "Processing file:\n%s" % path)
|
||||
|
||||
file = open(path, "r")
|
||||
srcString = file.read()
|
||||
@@ -955,38 +956,38 @@ class Fit(object):
|
||||
# If file had ANSI encoding, decode it to unicode using detection
|
||||
# of BOM header or if there is no header try default
|
||||
# codepage then fallback to utf-16, cp1252
|
||||
|
||||
|
||||
if isinstance(srcString, str):
|
||||
encoding_map = (
|
||||
('\xef\xbb\xbf', 'utf-8'),
|
||||
('\xff\xfe\0\0', 'utf-32'),
|
||||
('\0\0\xfe\xff', 'UTF-32BE'),
|
||||
('\xff\xfe', 'utf-16'),
|
||||
('\xfe\xff', 'UTF-16BE'))
|
||||
('\xef\xbb\xbf', 'utf-8'),
|
||||
('\xff\xfe\0\0', 'utf-32'),
|
||||
('\0\0\xfe\xff', 'UTF-32BE'),
|
||||
('\xff\xfe', 'utf-16'),
|
||||
('\xfe\xff', 'UTF-16BE'))
|
||||
|
||||
for bom, encoding in encoding_map:
|
||||
if srcString.startswith(bom):
|
||||
codec_found = encoding
|
||||
savebom = bom
|
||||
|
||||
|
||||
if codec_found is None:
|
||||
logger.info("Unicode BOM not found in file %s.", path)
|
||||
attempt_codecs = (defcodepage, "utf-8", "utf-16", "cp1252")
|
||||
|
||||
for page in attempt_codecs:
|
||||
try:
|
||||
logger.info("Attempting to decode file %s using %s page.", path, page)
|
||||
srcString = unicode(srcString, page)
|
||||
codec_found = page
|
||||
logger.info("File %s decoded using %s page.", path, page)
|
||||
except UnicodeDecodeError:
|
||||
logger.info("Error unicode decoding %s from page %s, trying next codec", path, page)
|
||||
else:
|
||||
break
|
||||
try:
|
||||
logger.info("Attempting to decode file %s using %s page.", path, page)
|
||||
srcString = unicode(srcString, page)
|
||||
codec_found = page
|
||||
logger.info("File %s decoded using %s page.", path, page)
|
||||
except UnicodeDecodeError:
|
||||
logger.info("Error unicode decoding %s from page %s, trying next codec", path, page)
|
||||
else:
|
||||
break
|
||||
else:
|
||||
logger.info("Unicode BOM detected in %s, using %s page.", path, codec_found)
|
||||
srcString = unicode(srcString[len(savebom):], codec_found)
|
||||
|
||||
|
||||
else:
|
||||
# nasty hack to detect other transparent utf-16 loading
|
||||
if srcString[0] == '<' and 'utf-16' in srcString[:128].lower():
|
||||
@@ -1001,10 +1002,10 @@ class Fit(object):
|
||||
_, fitsImport = Port.importAuto(srcString, path, callback=callback, encoding=codec_found)
|
||||
fits += fitsImport
|
||||
except xml.parsers.expat.ExpatError, e:
|
||||
return False, "Malformed XML in %s"%path
|
||||
return False, "Malformed XML in %s" % path
|
||||
except Exception, e:
|
||||
logger.exception("Unknown exception processing: %s", path)
|
||||
return False, "Unknown Error while processing %s"%path
|
||||
return False, "Unknown Error while processing %s" % path
|
||||
|
||||
IDs = []
|
||||
numFits = len(fits)
|
||||
@@ -1019,7 +1020,7 @@ class Fit(object):
|
||||
wx.CallAfter(
|
||||
callback, 1,
|
||||
"Processing complete, saving fits to database\n(%d/%d)" %
|
||||
(i+1, numFits)
|
||||
(i + 1, numFits)
|
||||
)
|
||||
|
||||
return True, fits
|
||||
@@ -1122,7 +1123,7 @@ class Fit(object):
|
||||
self.recalc(fit)
|
||||
|
||||
def recalc(self, fit, withBoosters=True):
|
||||
logger.debug("="*10+"recalc"+"="*10)
|
||||
logger.debug("=" * 10 + "recalc" + "=" * 10)
|
||||
if fit.factorReload is not self.serviceFittingOptions["useGlobalForceReload"]:
|
||||
fit.factorReload = self.serviceFittingOptions["useGlobalForceReload"]
|
||||
fit.clear()
|
||||
|
||||
@@ -22,7 +22,7 @@ import config
|
||||
import os
|
||||
import eos.types
|
||||
import eos.db.migration as migration
|
||||
import eos.db.saveddata.loadDefaultDatabaseValues as loadDefaultDatabaseValues
|
||||
from eos.db.saveddata.loadDefaultDatabaseValues import DefaultDatabaseValues
|
||||
|
||||
class PrefetchThread(threading.Thread):
|
||||
def run(self):
|
||||
@@ -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
|
||||
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()
|
||||
#Import default values for damage profiles
|
||||
importDBDefaults.importDamageProfileDefaults()
|
||||
#Import default values for target resist profiles
|
||||
importDBDefaults.importResistProfileDefaults()
|
||||
# Import values that must exist otherwise Pyfa breaks
|
||||
DefaultDatabaseValues.importRequiredDefaults()
|
||||
# Import default values for damage profiles
|
||||
DefaultDatabaseValues.importDamageProfileDefaults()
|
||||
# Import default values for target resist profiles
|
||||
DefaultDatabaseValues.importResistProfileDefaults()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user