From 03d1d8f5a4f74a7a0200be3ba175489022d16cfc Mon Sep 17 00:00:00 2001 From: Ebag333 Date: Wed, 15 Jun 2016 18:24:40 -0700 Subject: [PATCH 1/5] Merged changes from pyfa-org/master into branch Merged changes to see if we can clear up the merge conflict warning --- README.md | 2 +- eos/saveddata/module.py | 2 +- gui/builtinViewColumns/misc.py | 81 +++++++++++++++++++++------------- gui/itemStats.py | 29 +++++++++--- gui/mainMenuBar.py | 8 ++-- 5 files changed, 79 insertions(+), 43 deletions(-) diff --git a/README.md b/README.md index a5f89ee6d..d42f5a6fe 100644 --- a/README.md +++ b/README.md @@ -64,4 +64,4 @@ pyfa is licensed under the GNU GPL v3.0, see LICENSE * Email: sable.blitzmann@gmail.com ## CCP Copyright Notice -EVE Online, the EVE logo, EVE and all associated logos and designs are the intellectual property of CCP hf. All artwork, screenshots, characters, vehicles, storylines, world facts or other recognizable features of the intellectual property relating to these trademarks are likewise the intellectual property of CCP hf. EVE Online and the EVE logo are the registered trademarks of CCP hf. All rights are reserved worldwide. All other trademarks are the property of their respective owners. CCP hf. has granted permission to Osmium to use EVE Online and all associated logos and designs for promotional and information purposes on its website but does not endorse, and is not in any way affiliated with, Osmium. CCP is in no way responsible for the content on or functioning of this website, nor can it be liable for any damage arising from the use of this website. +EVE Online, the EVE logo, EVE and all associated logos and designs are the intellectual property of CCP hf. All artwork, screenshots, characters, vehicles, storylines, world facts or other recognizable features of the intellectual property relating to these trademarks are likewise the intellectual property of CCP hf. EVE Online and the EVE logo are the registered trademarks of CCP hf. All rights are reserved worldwide. All other trademarks are the property of their respective owners. CCP hf. has granted permission to pyfa to use EVE Online and all associated logos and designs for promotional and information purposes on its website but does not endorse, and is not in any way affiliated with, pyfa. CCP is in no way responsible for the content on or functioning of this program, nor can it be liable for any damage arising from the use of this program. diff --git a/eos/saveddata/module.py b/eos/saveddata/module.py index 42fd7cede..f5197f6f0 100644 --- a/eos/saveddata/module.py +++ b/eos/saveddata/module.py @@ -629,7 +629,7 @@ class Module(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut): @property def rawCycleTime(self): - speed = self.getModifiedItemAttr("speed") or self.getModifiedItemAttr("duration") + speed = self.getModifiedItemAttr("speed") or self.getModifiedItemAttr("duration") return speed @property diff --git a/gui/builtinViewColumns/misc.py b/gui/builtinViewColumns/misc.py index c50f23e47..9baee4726 100644 --- a/gui/builtinViewColumns/misc.py +++ b/gui/builtinViewColumns/misc.py @@ -210,42 +210,44 @@ class Miscellanea(ViewColumn): ladar = stuff.getModifiedItemAttr("scanLadarStrengthBonus") radar = stuff.getModifiedItemAttr("scanRadarStrengthBonus") magnet = stuff.getModifiedItemAttr("scanMagnetometricStrengthBonus") - if grav is None or ladar is None or radar is None or magnet is None: + displayMax = max(grav, ladar, radar, magnet) + displayMin = min(grav, ladar, radar, magnet) + if grav is None or ladar is None or radar is None or magnet is None or displayMax is None: return "", None - display = max(grav, ladar, radar, magnet) - if not display: - return "", None - text = "{0}".format(formatAmount(display, 3, 0, 3)) - ttEntries = [] - if display == grav: - ttEntries.append("gravimetric") - if display == ladar: - ttEntries.append("ladar") - if display == magnet: - ttEntries.append("magnetometric") - if display == radar: - ttEntries.append("radar") - plu = "" if len(ttEntries) == 1 else "s" - tooltip = "{0} strength{1}".format(formatList(ttEntries), plu).capitalize() + + if displayMax == displayMin or displayMin is None: + text = "{0}".format( + formatAmount(displayMax, 3, 0, 3), + ) + else: + text = "{0} | {1}".format( + formatAmount(displayMax, 3, 0, 3), + formatAmount(displayMin, 3, 0, 3), + ) + tooltip = "ECM Jammer Strength:\n{0} Gravimetric | {1} Ladar | {2} Magnetometric | {3} Radar".format( + formatAmount(grav, 3, 0, 3), + formatAmount(ladar, 3, 0, 3), + formatAmount(radar, 3, 0, 3), + formatAmount(magnet, 3, 0, 3), + ) return text, tooltip elif itemGroup in ("Remote Sensor Booster", "Sensor Booster", "Signal Amplifier"): scanResBonus = stuff.getModifiedItemAttr("scanResolutionBonus") lockRangeBonus = stuff.getModifiedItemAttr("maxTargetRangeBonus") - if scanResBonus is None or lockRangeBonus is None: + gravBonus = stuff.getModifiedItemAttr("scanGravimetricStrengthPercent") + if scanResBonus is None or lockRangeBonus is None or gravBonus is None: return "", None - display = 0 - for bonus in (scanResBonus, lockRangeBonus): - if abs(bonus) > abs(display): - display = bonus - if not display: - return "", None - text = "{0}%".format(formatAmount(display, 3, 0, 3, forceSign=True)) - ttEntries = [] - if display == lockRangeBonus: - ttEntries.append("lock range") - if display == scanResBonus: - ttEntries.append("scan resolution") - tooltip = "{0} bonus".format(formatList(ttEntries)).capitalize() + + text = "{0}% | {1}% | {2}%".format( + formatAmount(scanResBonus, 3, 0, 3), + formatAmount(lockRangeBonus, 3, 0, 3), + formatAmount(gravBonus, 3, 0, 3), + ) + tooltip = "Applied bonuses:\n{0}% scan resolution | {1}% lock range | {2}% sensor strength".format( + formatAmount(scanResBonus, 3, 0, 3), + formatAmount(lockRangeBonus, 3, 0, 3), + formatAmount(gravBonus, 3, 0, 3), + ) return text, tooltip elif itemGroup in ("Projected ECCM", "ECCM", "Sensor Backup Array"): grav = stuff.getModifiedItemAttr("scanGravimetricStrengthPercent") @@ -483,6 +485,25 @@ class Miscellanea(ViewColumn): duration = cycles * cycleTime / 1000 text = "{0} / {1}s".format(formatAmount(ehp, 3, 0, 9), formatAmount(duration, 3, 0, 3)) + return text, tooltip + elif itemGroup == "Armor Resistance Shift Hardener": + itemArmorResistanceShiftHardenerEM = (1-stuff.getModifiedItemAttr("armorEmDamageResonance"))*100 + itemArmorResistanceShiftHardenerTherm = (1-stuff.getModifiedItemAttr("armorThermalDamageResonance")) * 100 + itemArmorResistanceShiftHardenerKin = (1-stuff.getModifiedItemAttr("armorKineticDamageResonance")) * 100 + itemArmorResistanceShiftHardenerExp = (1-stuff.getModifiedItemAttr("armorExplosiveDamageResonance")) * 100 + + text = "{0}% | {1}% | {2}% | {3}%".format( + formatAmount(itemArmorResistanceShiftHardenerEM, 3, 0, 3), + formatAmount(itemArmorResistanceShiftHardenerTherm, 3, 0, 3), + formatAmount(itemArmorResistanceShiftHardenerKin, 3, 0, 3), + formatAmount(itemArmorResistanceShiftHardenerExp, 3, 0, 3), + ) + tooltip = "Resistances Shifted to Damage Profile:\n{0}% EM | {1}% Therm | {2}% Kin | {3}% Exp".format( + formatAmount(itemArmorResistanceShiftHardenerEM, 3, 0, 3), + formatAmount(itemArmorResistanceShiftHardenerTherm, 3, 0, 3), + formatAmount(itemArmorResistanceShiftHardenerKin, 3, 0, 3), + formatAmount(itemArmorResistanceShiftHardenerExp, 3, 0, 3), + ) return text, tooltip elif stuff.charge is not None: chargeGroup = stuff.charge.group.name diff --git a/gui/itemStats.py b/gui/itemStats.py index ad3e49b6c..c64164a47 100644 --- a/gui/itemStats.py +++ b/gui/itemStats.py @@ -84,9 +84,9 @@ class ItemStatsDialog(wx.Dialog): self.SetMinSize((300, 200)) if "wxGTK" in wx.PlatformInfo: # GTK has huge tab widgets, give it a bit more room - self.SetSize((530, 300)) + self.SetSize((580, 500)) else: - self.SetSize((500, 300)) + self.SetSize((550, 500)) #self.SetMaxSize((500, -1)) self.mainSizer = wx.BoxSizer(wx.VERTICAL) self.container = ItemStatsContainer(self, victim, item, itmContext) @@ -341,9 +341,14 @@ class ItemParams (wx.Panel): def PopulateList(self): self.paramList.InsertColumn(0,"Attribute") - self.paramList.InsertColumn(1,"Value") - self.paramList.SetColumnWidth(1,150) - self.paramList.setResizeColumn(1) + self.paramList.InsertColumn(1,"Current Value") + if self.stuff is not None: + self.paramList.InsertColumn(2,"Base Value") + self.paramList.SetColumnWidth(0,110) + self.paramList.SetColumnWidth(1,90) + if self.stuff is not None: + self.paramList.SetColumnWidth(2,90) + self.paramList.setResizeColumn(0) self.imageList = wx.ImageList(16, 16) self.paramList.SetImageList(self.imageList,wx.IMAGE_LIST_SMALL) @@ -354,9 +359,11 @@ class ItemParams (wx.Panel): idCount = 0 for name in names: info = self.attrInfo.get(name) - - att = self.attrValues[name] + + valDefault = getattr(info, "value", None) + valueDefault = valDefault if valDefault is not None else att + val = getattr(att, "value", None) value = val if val is not None else att @@ -395,8 +402,16 @@ class ItemParams (wx.Panel): else: valueUnit = formatAmount(value, 3, 0, 0) + if self.toggleView != 1: + valueUnitDefault = str(valueDefault) + elif info and info.unit: + valueUnitDefault = self.TranslateValueUnit(valueDefault, info.unit.displayName, info.unit.name) + else: + valueUnitDefault = formatAmount(valueDefault, 3, 0, 0) self.paramList.SetStringItem(index, 1, valueUnit) + if self.stuff is not None: + self.paramList.SetStringItem(index, 2, valueUnitDefault) diff --git a/gui/mainMenuBar.py b/gui/mainMenuBar.py index 169ed4e6c..bbae75cfd 100644 --- a/gui/mainMenuBar.py +++ b/gui/mainMenuBar.py @@ -74,8 +74,6 @@ class MainMenuBar(wx.MenuBar): fileMenu.Append(self.exportSkillsNeededId, "Export &Skills Needed", "Export skills needed for this fitting") fileMenu.Append(self.importCharacterId, "Import C&haracter File", "Import characters into pyfa from file") fileMenu.AppendSeparator() - fileMenu.Append(self.importDatabaseDefaultsId, "Import D&atabase Defaults", "Imports missing database defaults") - fileMenu.AppendSeparator() fileMenu.Append(wx.ID_EXIT) # Edit menu @@ -139,11 +137,11 @@ class MainMenuBar(wx.MenuBar): self.Enable(self.exportToEveId, False) if not gui.mainFrame.disableOverrideEditor: + windowMenu.AppendSeparator() attrItem = wx.MenuItem(windowMenu, self.attrEditorId, "Attribute Overrides\tCTRL+B") attrItem.SetBitmap(BitmapLoader.getBitmap("fit_rename_small", "gui")) windowMenu.AppendItem(attrItem) - editMenu.AppendSeparator() - editMenu.Append(self.toggleOverridesId, "Turn Overrides On") + windowMenu.Append(self.toggleOverridesId, "Turn Overrides On") # Help menu helpMenu = wx.Menu() @@ -151,6 +149,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: From 47828c38d25ccdf767005d372a7a3f906e398604 Mon Sep 17 00:00:00 2001 From: Ebag333 Date: Wed, 15 Jun 2016 19:40:45 -0700 Subject: [PATCH 2/5] Merged differences from master (more catching up) --- eos/effects/adaptivearmorhardener.py | 8 ++++ eos/effects/fighterabilitylaunchbomb.py | 3 ++ eos/effects/fighterabilitymissiles.py | 3 ++ eos/saveddata/fighterAbility.py | 34 ++++++++++++++- gui/builtinViews/fittingView.py | 16 ++++++- service/fit.py | 57 ++++++++++++------------- 6 files changed, 90 insertions(+), 31 deletions(-) diff --git a/eos/effects/adaptivearmorhardener.py b/eos/effects/adaptivearmorhardener.py index f2951320b..c3955ebf0 100644 --- a/eos/effects/adaptivearmorhardener.py +++ b/eos/effects/adaptivearmorhardener.py @@ -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") diff --git a/eos/effects/fighterabilitylaunchbomb.py b/eos/effects/fighterabilitylaunchbomb.py index 5a9513e1d..bc76f2a19 100644 --- a/eos/effects/fighterabilitylaunchbomb.py +++ b/eos/effects/fighterabilitylaunchbomb.py @@ -11,5 +11,8 @@ prefix = "fighterAbilityLaunchBomb" type = "active" +# This flag is required for effects that use charges in order to properly calculate reload time +hasCharges = True + def handler(fit, src, context): pass \ No newline at end of file diff --git a/eos/effects/fighterabilitymissiles.py b/eos/effects/fighterabilitymissiles.py index 7615f5616..c002ea5ac 100644 --- a/eos/effects/fighterabilitymissiles.py +++ b/eos/effects/fighterabilitymissiles.py @@ -11,5 +11,8 @@ prefix = "fighterAbilityMissiles" type = "active" +# This flag is required for effects that use charges in order to properly calculate reload time +hasCharges = True + def handler(fit, src, context): pass \ No newline at end of file diff --git a/eos/saveddata/fighterAbility.py b/eos/saveddata/fighterAbility.py index e7756bde1..027ffa30f 100644 --- a/eos/saveddata/fighterAbility.py +++ b/eos/saveddata/fighterAbility.py @@ -26,6 +26,14 @@ class FighterAbility(object): DAMAGE_TYPES = ("em", "kinetic", "explosive", "thermal") DAMAGE_TYPES2 = ("EM", "Kin", "Exp", "Therm") + # We aren't able to get data on the charges that can be stored with fighters. So we hardcode that data here, keyed + # with the fighter squadron role + NUM_SHOTS_MAPPING = { + 2: 8, # Light fighter / Attack + 4: 6, # Heavy fighter / Heavy attack + 5: 2, # Heavy fighter / Long range attack + } + def __init__(self, effect): """Initialize from the program""" self.__effect = effect @@ -71,12 +79,36 @@ class FighterAbility(object): # is the ability applied per fighter (webs, returns False), or as a group (MWD, returned True) return self.__effect.getattr('grouped') + @property + def hasCharges(self): + return self.__effect.getattr('hasCharges') + + @property + def reloadTime(self): + return self.fighter.getModifiedItemAttr("fighterRefuelingTime") * self.numShots + + @property + def numShots(self): + return self.NUM_SHOTS_MAPPING[self.fighter.getModifiedItemAttr("fighterSquadronRole")] or 0 if self.hasCharges else 0 + + @property + def cycleTime(self): + speed = self.fighter.getModifiedItemAttr("{}Duration".format(self.attrPrefix)) + reload = self.reloadTime + + if self.fighter.owner.factorReload: + numShots = self.numShots + # Speed here already takes into consideration reactivation time + speed = (speed * numShots + reload) / numShots if numShots > 0 else speed + + return speed + def damageStats(self, targetResists=None): if self.__dps is None: self.__volley = 0 self.__dps = 0 if self.dealsDamage and self.active: - cycleTime = self.fighter.getModifiedItemAttr("{}Duration".format(self.attrPrefix)) + cycleTime = self.cycleTime if self.attrPrefix == "fighterAbilityLaunchBomb": # bomb calcs diff --git a/gui/builtinViews/fittingView.py b/gui/builtinViews/fittingView.py index d16c0f251..7db037082 100644 --- a/gui/builtinViews/fittingView.py +++ b/gui/builtinViews/fittingView.py @@ -186,7 +186,7 @@ class FittingView(d.Display): elif data[0] == "cargo": self.swapCargo(x, y, int(data[1])) elif data[0] == "market": - wx.PostEvent(self.mainFrame, gui.marketBrowser.ItemSelected(itemID=int(data[1]))) + self.addModule(x, y, int(data[1])) def handleDrag(self, type, fitID): #Those are drags coming from pyfa sources, NOT builtin wx drags @@ -343,6 +343,20 @@ class FittingView(d.Display): self.slotsChanged() wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.activeFitID)) + def addModule(self, x, y, srcIdx): + '''Add a module from the market browser''' + mstate = wx.GetMouseState() + + dstRow, _ = self.HitTest((x, y)) + if dstRow != -1 and dstRow not in self.blanks: + sFit = service.Fit.getInstance() + fitID = self.mainFrame.getActiveFit() + moduleChanged = sFit.changeModule(fitID, self.mods[dstRow].position, srcIdx) + if moduleChanged is None: + # the new module doesn't fit in specified slot, try to simply append it + wx.PostEvent(self.mainFrame, gui.marketBrowser.ItemSelected(itemID=srcIdx)) + wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.mainFrame.getActiveFit())) + def swapCargo(self, x, y, srcIdx): '''Swap a module from cargo to fitting window''' mstate = wx.GetMouseState() diff --git a/service/fit.py b/service/fit.py index 71f8c873d..8ae9c6e4d 100644 --- a/service/fit.py +++ b/service/fit.py @@ -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 . -#=============================================================================== +# =============================================================================== 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) @@ -477,8 +478,6 @@ class Fit(object): def changeModule(self, fitID, position, newItemID): fit = eos.db.getFit(fitID) - if fit.modules[position].isEmpty: - return None # Dummy it out in case the next bit fails fit.modules.toDummy(position) @@ -945,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() @@ -957,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(): @@ -1003,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) @@ -1021,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 @@ -1124,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() From 12ccc96f468fdecef7265c8ecff2a32ef5a4f285 Mon Sep 17 00:00:00 2001 From: Ebag333 Date: Wed, 15 Jun 2016 23:42:38 -0700 Subject: [PATCH 3/5] Updated as per Blitzmanns feedback https://github.com/pyfa-org/Pyfa/pull/639#issuecomment-225749245 --- eos/db/saveddata/loadDefaultDatabaseValues.py | 28 +++++++++++-------- service/damagePattern.py | 3 +- service/prefetch.py | 10 ++++--- 3 files changed, 23 insertions(+), 18 deletions(-) diff --git a/eos/db/saveddata/loadDefaultDatabaseValues.py b/eos/db/saveddata/loadDefaultDatabaseValues.py index 6eb38ef1d..1533c014b 100644 --- a/eos/db/saveddata/loadDefaultDatabaseValues.py +++ b/eos/db/saveddata/loadDefaultDatabaseValues.py @@ -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) diff --git a/service/damagePattern.py b/service/damagePattern.py index b379c5ed7..27e0591ad 100644 --- a/service/damagePattern.py +++ b/service/damagePattern.py @@ -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() diff --git a/service/prefetch.py b/service/prefetch.py index 4d7330728..56554176c 100644 --- a/service/prefetch.py +++ b/service/prefetch.py @@ -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() From b79009517e6e2d05ff93c53baeba5275f8fc9b12 Mon Sep 17 00:00:00 2001 From: Ebag333 Date: Thu, 16 Jun 2016 14:46:22 -0700 Subject: [PATCH 4/5] Updated po-ta-toe to po-tah-toh --- eos/db/saveddata/loadDefaultDatabaseValues.py | 2 +- gui/mainFrame.py | 10 ++++------ service/damagePattern.py | 7 +++++-- service/prefetch.py | 16 ++++++++-------- 4 files changed, 18 insertions(+), 17 deletions(-) diff --git a/eos/db/saveddata/loadDefaultDatabaseValues.py b/eos/db/saveddata/loadDefaultDatabaseValues.py index 1533c014b..8661e23fa 100644 --- a/eos/db/saveddata/loadDefaultDatabaseValues.py +++ b/eos/db/saveddata/loadDefaultDatabaseValues.py @@ -23,7 +23,7 @@ import eos.types class ImportError(Exception): pass -class defaultDatabaseValues(): +class DefaultDatabaseValues(): instance = None @classmethod diff --git a/gui/mainFrame.py b/gui/mainFrame.py index 91e16566a..74918118f 100644 --- a/gui/mainFrame.py +++ b/gui/mainFrame.py @@ -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() diff --git a/service/damagePattern.py b/service/damagePattern.py index 27e0591ad..6723e85ec 100644 --- a/service/damagePattern.py +++ b/service/damagePattern.py @@ -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 @@ -37,7 +38,9 @@ class DamagePattern(): def __init__(self): uniform = eos.db.getDamagePattern("Uniform") if uniform is None: - loadDefaultDatabaseValues.defaultDatabaseValues.importRequiredDefaults() + # Import default database values + # Import values that must exist otherwise Pyfa breaks + DefaultDatabaseValues.importRequiredDefaults() def getDamagePatternList(self): return eos.db.getDamagePatternList() diff --git a/service/prefetch.py b/service/prefetch.py index 56554176c..b16f52d40 100644 --- a/service/prefetch.py +++ b/service/prefetch.py @@ -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): @@ -54,17 +54,17 @@ if os.path.isfile(config.saveDB): migration.update(eos.db.saveddata_engine) # Import default database values # Import values that must exist otherwise Pyfa breaks - loadDefaultDatabaseValues.defaultDatabaseValues.importRequiredDefaults() + 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 - #Import values that must exist otherwise Pyfa breaks - loadDefaultDatabaseValues.defaultDatabaseValues.importRequiredDefaults() - #Import default values for damage profiles - loadDefaultDatabaseValues.defaultDatabaseValues.importDamageProfileDefaults() - #Import default values for target resist profiles - loadDefaultDatabaseValues.defaultDatabaseValues.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() From 0f958bef81beb196eaa7bc7155cbd9e55ae3e3df Mon Sep 17 00:00:00 2001 From: Ebag333 Date: Thu, 16 Jun 2016 19:08:29 -0700 Subject: [PATCH 5/5] Removed _init_ definition as it's redundant --- service/damagePattern.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/service/damagePattern.py b/service/damagePattern.py index 6723e85ec..f617fa846 100644 --- a/service/damagePattern.py +++ b/service/damagePattern.py @@ -35,13 +35,6 @@ class DamagePattern(): return cls.instance - def __init__(self): - uniform = eos.db.getDamagePattern("Uniform") - if uniform is None: - # Import default database values - # Import values that must exist otherwise Pyfa breaks - DefaultDatabaseValues.importRequiredDefaults() - def getDamagePatternList(self): return eos.db.getDamagePatternList()