From 11d7f9d02926f82815aa6f57daaea4fd1125c940 Mon Sep 17 00:00:00 2001 From: Ebag333 Date: Thu, 9 Feb 2017 00:04:41 -0800 Subject: [PATCH] Make modules static if they do not use self. --- eos/graph/__init__.py | 6 +- eos/graph/fitDps.py | 12 ++- eos/saveddata/booster.py | 3 +- eos/saveddata/fit.py | 6 +- eos/saveddata/implant.py | 3 +- eos/saveddata/module.py | 6 +- gui/PFSearchBox.py | 3 +- gui/builtinContextMenus/amount.py | 3 +- gui/builtinContextMenus/moduleAmmoPicker.py | 6 +- .../pyfaGaugePreferences.py | 3 +- gui/chromeTabs.py | 12 ++- gui/commandView.py | 6 +- gui/crestFittings.py | 3 +- gui/fighterView.py | 3 +- gui/itemStats.py | 9 +- gui/mainFrame.py | 9 +- gui/projectedView.py | 9 +- gui/pygauge.py | 3 +- gui/sfBrowserItem.py | 6 +- gui/shipBrowser.py | 21 +++-- gui/statsPane.py | 3 +- service/attribute.py | 3 +- service/character.py | 93 ++++++++++++------- service/damagePattern.py | 21 +++-- service/fit.py | 51 ++++++---- service/implantSet.py | 30 ++++-- service/market.py | 24 +++-- service/port.py | 12 ++- service/pycrest/eve.py | 3 +- service/targetResists.py | 21 +++-- service/update.py | 6 +- 31 files changed, 266 insertions(+), 133 deletions(-) diff --git a/eos/graph/__init__.py b/eos/graph/__init__.py index 7127afa73..44802171f 100644 --- a/eos/graph/__init__.py +++ b/eos/graph/__init__.py @@ -93,7 +93,8 @@ class Constant(object): def __iter__(self): yield self.value - def isConstant(self): + @staticmethod + def isConstant(): return True @@ -114,5 +115,6 @@ class Range(object): i += 1 yield current - def isConstant(self): + @staticmethod + def isConstant(): return False diff --git a/eos/graph/fitDps.py b/eos/graph/fitDps.py index 7603be598..a13a41cc5 100644 --- a/eos/graph/fitDps.py +++ b/eos/graph/fitDps.py @@ -95,7 +95,8 @@ class FitDpsGraph(Graph): return total - def calculateMissileMultiplier(self, mod, data): + @staticmethod + def calculateMissileMultiplier(mod, data): targetSigRad = data["signatureRadius"] targetVelocity = data["velocity"] explosionRadius = mod.getModifiedChargeAttr("aoeCloudSize") @@ -126,7 +127,8 @@ class FitDpsGraph(Graph): multiplier = min(1, (float(targetSigRad) / dmgScaling) ** 2) return multiplier - def calculateFighterMissileMultiplier(self, ability, data): + @staticmethod + def calculateFighterMissileMultiplier(ability, data): prefix = ability.attrPrefix targetSigRad = data["signatureRadius"] @@ -156,7 +158,8 @@ class FitDpsGraph(Graph): return min(sigRadiusFactor, velocityFactor, 1) - def calculateTurretChanceToHit(self, mod, data): + @staticmethod + def calculateTurretChanceToHit(mod, data): distance = data["distance"] * 1000 tracking = mod.getModifiedItemAttr("trackingSpeed") turretOptimal = mod.maxRange @@ -171,7 +174,8 @@ class FitDpsGraph(Graph): return 0.5 ** (trackingEq + rangeEq) - def calculateModuleMultiplier(self, mod, data): + @staticmethod + def calculateModuleMultiplier(mod, data): # Simplified formula, we make some assumptions about the module # This is basically the calculateTurretChanceToHit without tracking values distance = data["distance"] * 1000 diff --git a/eos/saveddata/booster.py b/eos/saveddata/booster.py index 93f0a4bc3..97a90cde0 100644 --- a/eos/saveddata/booster.py +++ b/eos/saveddata/booster.py @@ -103,7 +103,8 @@ class Booster(HandledItem, ItemAttrShortcut): def item(self): return self.__item - def __calculateSlot(self, item): + @staticmethod + def __calculateSlot(item): if "boosterness" not in item.attributes: raise ValueError("Passed item is not a booster") diff --git a/eos/saveddata/fit.py b/eos/saveddata/fit.py index 359ba6a0f..3b4b7a99f 100644 --- a/eos/saveddata/fit.py +++ b/eos/saveddata/fit.py @@ -796,7 +796,8 @@ class Fit(object): x += 1 return x - def getItemAttrSum(self, dict, attr): + @staticmethod + def getItemAttrSum(dict, attr): amount = 0 for mod in dict: add = mod.getModifiedItemAttr(attr) @@ -805,7 +806,8 @@ class Fit(object): return amount - def getItemAttrOnlineSum(self, dict, attr): + @staticmethod + def getItemAttrOnlineSum(dict, attr): amount = 0 for mod in dict: add = mod.getModifiedItemAttr(attr) if mod.state >= State.ONLINE else None diff --git a/eos/saveddata/implant.py b/eos/saveddata/implant.py index a77190bc4..837642ca6 100644 --- a/eos/saveddata/implant.py +++ b/eos/saveddata/implant.py @@ -78,7 +78,8 @@ class Implant(HandledItem, ItemAttrShortcut): def item(self): return self.__item - def __calculateSlot(self, item): + @staticmethod + def __calculateSlot(item): if "implantness" not in item.attributes: raise ValueError("Passed item is not an implant") diff --git a/eos/saveddata/module.py b/eos/saveddata/module.py index 81e270cb2..993d54765 100644 --- a/eos/saveddata/module.py +++ b/eos/saveddata/module.py @@ -547,7 +547,8 @@ class Module(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut): return validCharges - def __calculateHardpoint(self, item): + @staticmethod + def __calculateHardpoint(item): effectHardpointMap = {"turretFitted": Hardpoint.TURRET, "launcherFitted": Hardpoint.MISSILE} @@ -560,7 +561,8 @@ class Module(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut): return Hardpoint.NONE - def __calculateSlot(self, item): + @staticmethod + def __calculateSlot(item): effectSlotMap = {"rigSlot": Slot.RIG, "loPower": Slot.LOW, "medPower": Slot.MED, diff --git a/gui/PFSearchBox.py b/gui/PFSearchBox.py index 8a5cd369c..f5f8d8c6d 100644 --- a/gui/PFSearchBox.py +++ b/gui/PFSearchBox.py @@ -69,7 +69,8 @@ class PFSearchBox(wx.Window): wx.PostEvent(self, TextEnter()) event.Skip() - def OnEditSetFocus(self, event): + @staticmethod + def OnEditSetFocus(event): # value = self.EditBox.GetValue() # if value == self.descriptiveText: # self.EditBox.ChangeValue("") diff --git a/gui/builtinContextMenus/amount.py b/gui/builtinContextMenus/amount.py index 3d51a1963..95dba33f4 100644 --- a/gui/builtinContextMenus/amount.py +++ b/gui/builtinContextMenus/amount.py @@ -71,7 +71,8 @@ class AmountChanger(wx.Dialog): event.Skip() # checks to make sure it's valid number - def onChar(self, event): + @staticmethod + def onChar(event): key = event.GetKeyCode() acceptable_characters = "1234567890" diff --git a/gui/builtinContextMenus/moduleAmmoPicker.py b/gui/builtinContextMenus/moduleAmmoPicker.py index ef0a8a742..b6791662d 100644 --- a/gui/builtinContextMenus/moduleAmmoPicker.py +++ b/gui/builtinContextMenus/moduleAmmoPicker.py @@ -97,7 +97,8 @@ class ModuleAmmoPicker(ContextMenu): return chargeDamageType, totalDamage - def numericConverter(self, string): + @staticmethod + def numericConverter(string): return int(string) if string.isdigit() else string def nameSorter(self, charge): @@ -118,7 +119,8 @@ class ModuleAmmoPicker(ContextMenu): return item - def addSeperator(self, m, text): + @staticmethod + def addSeperator(m, text): id_ = ContextMenu.nextID() m.Append(id_, u'─ %s ─' % text) m.Enable(id_, False) diff --git a/gui/builtinPreferenceViews/pyfaGaugePreferences.py b/gui/builtinPreferenceViews/pyfaGaugePreferences.py index c7d832a88..5f6509dc0 100644 --- a/gui/builtinPreferenceViews/pyfaGaugePreferences.py +++ b/gui/builtinPreferenceViews/pyfaGaugePreferences.py @@ -426,7 +426,8 @@ class PFGaugePref(PreferenceView): self.SetColours() event.Skip() - def OnOk(self, event): + @staticmethod + def OnOk(event): # Apply New Settings event.Skip() diff --git a/gui/chromeTabs.py b/gui/chromeTabs.py index 600a49950..db4084e52 100644 --- a/gui/chromeTabs.py +++ b/gui/chromeTabs.py @@ -148,7 +148,8 @@ class PFNotebook(wx.Panel): if self.activePage == page: self.ShowActive() - def GetBorders(self): + @staticmethod + def GetBorders(): """Gets border widths to better determine page size in ShowActive()""" bx = wx.SystemSettings_GetMetric(wx.SYS_BORDER_X) @@ -440,7 +441,8 @@ class PFTabRenderer(object): def SetTabImage(self, img): self.tabImg = img - def CopyRegion(self, region): + @staticmethod + def CopyRegion(region): rect = region.GetBox() newRegion = wx.Region(rect.X, rect.Y, rect.Width, rect.Height) @@ -654,7 +656,8 @@ class PFAddRenderer(object): region = wx.RegionFromBitmap(self.tbmp) return region - def CopyRegion(self, region): + @staticmethod + def CopyRegion(region): rect = region.GetBox() newRegion = wx.Region(rect.X, rect.Y, rect.Width, rect.Height) @@ -975,7 +978,8 @@ class PFTabsContainer(wx.Panel): return tab return None - def TabHitTest(self, tab, x, y): + @staticmethod + def TabHitTest(tab, x, y): tabRegion = tab.GetTabRegion() tabPos = tab.GetPosition() tabPosX, tabPosY = tabPos diff --git a/gui/commandView.py b/gui/commandView.py index c47832451..fc0f1de47 100644 --- a/gui/commandView.py +++ b/gui/commandView.py @@ -80,7 +80,8 @@ class CommandView(d.Display): self.Bind(wx.EVT_LIST_BEGIN_DRAG, self.startDrag) self.SetDropTarget(CommandViewDrop(self.handleListDrag)) - def handleListDrag(self, x, y, data): + @staticmethod + def handleListDrag(x, y, data): """ Handles dragging of items from various pyfa displays which support it @@ -120,7 +121,8 @@ class CommandView(d.Display): dropSource.SetData(data) dropSource.DoDragDrop() - def fitSort(self, fit): + @staticmethod + def fitSort(fit): return fit.name def fitChanged(self, event): diff --git a/gui/crestFittings.py b/gui/crestFittings.py index 9eb625d04..181841712 100644 --- a/gui/crestFittings.py +++ b/gui/crestFittings.py @@ -340,7 +340,8 @@ class CrestMgmt(wx.Dialog): self.lcCharacters.SetColumnWidth(0, wx.LIST_AUTOSIZE) self.lcCharacters.SetColumnWidth(1, wx.LIST_AUTOSIZE) - def addChar(self, event): + @staticmethod + def addChar(event): sCrest = Crest.getInstance() uri = sCrest.startServer() webbrowser.open(uri) diff --git a/gui/fighterView.py b/gui/fighterView.py index 79923daa2..292b7fb80 100644 --- a/gui/fighterView.py +++ b/gui/fighterView.py @@ -207,7 +207,8 @@ class FighterDisplay(d.Display): elif data[0] == "market": wx.PostEvent(self.mainFrame, mb.ItemSelected(itemID=int(data[1]))) - def _merge(self, src, dst): + @staticmethod + def _merge(src, dst): return ''' diff --git a/gui/itemStats.py b/gui/itemStats.py index e14ecc27a..a29340d61 100644 --- a/gui/itemStats.py +++ b/gui/itemStats.py @@ -482,7 +482,8 @@ class ItemParams(wx.Panel): self.totalAttrsLabel.SetLabel("%d attributes. " % idCount) self.Layout() - def TranslateValueUnit(self, value, unitName, unitDisplayName): + @staticmethod + def TranslateValueUnit(value, unitName, unitDisplayName): def itemIDCallback(): item = Market.getInstance().getItem(value) return "%s (%d)" % (item.name, value) if item is not None else str(value) @@ -674,7 +675,8 @@ class ItemCompare(wx.Panel): self.paramList.RefreshRows() self.Layout() - def TranslateValueUnit(self, value, unitName, unitDisplayName): + @staticmethod + def TranslateValueUnit(value, unitName, unitDisplayName): def itemIDCallback(): item = Market.getInstance().getItem(value) return "%s (%d)" % (item.name, value) if item is not None else str(value) @@ -840,7 +842,8 @@ class ItemEffects(wx.Panel): self.RefreshValues(event) - def OnRightClick(self, event): + @staticmethod + def OnRightClick(event): """ Debug use: open effect file with default application. If effect file does not exist, create it diff --git a/gui/mainFrame.py b/gui/mainFrame.py index ec8845884..175e14ab2 100644 --- a/gui/mainFrame.py +++ b/gui/mainFrame.py @@ -442,13 +442,16 @@ class MainFrame(wx.Frame): dlg = PreferenceDialog(self) dlg.ShowModal() - def goWiki(self, event): + @staticmethod + def goWiki(event): webbrowser.open('https://github.com/pyfa-org/Pyfa/wiki') - def goForums(self, event): + @staticmethod + def goForums(event): webbrowser.open('https://forums.eveonline.com/default.aspx?g=posts&t=466425') - def loadDatabaseDefaults(self, event): + @staticmethod + def loadDatabaseDefaults(event): # Import values that must exist otherwise Pyfa breaks DefaultDatabaseValues.importRequiredDefaults() # Import default values for damage profiles diff --git a/gui/projectedView.py b/gui/projectedView.py index 40cde2e3b..2447438d9 100644 --- a/gui/projectedView.py +++ b/gui/projectedView.py @@ -148,10 +148,12 @@ class ProjectedView(d.Display): if sFit.mergeDrones(fitID, self.get(src), dstDrone, True): wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID)) - def moduleSort(self, module): + @staticmethod + def moduleSort(module): return module.item.name - def fighterSort(self, fighter): + @staticmethod + def fighterSort(fighter): return fighter.item.name def droneSort(self, drone): @@ -162,7 +164,8 @@ class ProjectedView(d.Display): return (self.droneView.DRONE_ORDER.index(item.marketGroup.name), drone.item.name) - def fitSort(self, fit): + @staticmethod + def fitSort(fit): return fit.name def fitChanged(self, event): diff --git a/gui/pygauge.py b/gui/pygauge.py index 3020bd2e7..6287bbdf6 100644 --- a/gui/pygauge.py +++ b/gui/pygauge.py @@ -264,7 +264,8 @@ class PyGauge(wx.PyWindow): self.Animate() self._tooltip.SetTip("%.2f/%.2f" % (self._value, self._range if self._range > 0.01 else 0)) - def OnEraseBackground(self, event): + @staticmethod + def OnEraseBackground(event): """ Handles the ``wx.EVT_ERASE_BACKGROUND`` event for L{PyGauge}. diff --git a/gui/sfBrowserItem.py b/gui/sfBrowserItem.py index 471ef04c4..6ecdb0f9a 100644 --- a/gui/sfBrowserItem.py +++ b/gui/sfBrowserItem.py @@ -197,7 +197,8 @@ class PFToolbar(object): return height - def HitTest(self, target, position, area): + @staticmethod + def HitTest(target, position, area): x, y = target px, py = position aX, aY = area @@ -355,7 +356,8 @@ class SFBrowserItem(wx.Window): event.Skip() - def GetType(self): + @staticmethod + def GetType(): return -1 def SetSelected(self, select=True): diff --git a/gui/shipBrowser.py b/gui/shipBrowser.py index d91077176..90b624a41 100644 --- a/gui/shipBrowser.py +++ b/gui/shipBrowser.py @@ -458,7 +458,8 @@ class NavigationPanel(SFItem.SFBrowserItem): stage, data = self.shipBrowser.browseHist.pop() self.gotoStage(stage, data) - def AdjustChannels(self, bitmap): + @staticmethod + def AdjustChannels(bitmap): img = wx.ImageFromBitmap(bitmap) img = img.AdjustChannels(1.05, 1.05, 1.05, 1) return wx.BitmapFromImage(img) @@ -800,7 +801,8 @@ class ShipBrowser(wx.Panel): self.navpanel.ShowNewFitButton(False) self.navpanel.ShowSwitchEmptyGroupsButton(True) - def nameKey(self, info): + @staticmethod + def nameKey(info): return info[1] def stage3(self, event): @@ -972,7 +974,8 @@ class PFStaticText(wx.Panel): self.SetSizer(mainSizer) self.Layout() - def GetType(self): + @staticmethod + def GetType(): return -1 @@ -1031,7 +1034,8 @@ class CategoryItem(SFItem.SFBrowserItem): self.animTimer.Stop() self.Refresh() - def OUT_QUAD(self, t, b, c, d): + @staticmethod + def OUT_QUAD(t, b, c, d): t = float(t) b = float(b) c = float(c) @@ -1204,7 +1208,8 @@ class ShipItem(SFItem.SFBrowserItem): self.animTimer.Stop() self.Refresh() - def OUT_QUAD(self, t, b, c, d): + @staticmethod + def OUT_QUAD(t, b, c, d): t = float(t) b = float(b) c = float(c) @@ -1644,10 +1649,12 @@ class FitItem(SFItem.SFBrowserItem): self.animTimer.Stop() self.Refresh() - def CalculateDelta(self, start, end, delta): + @staticmethod + def CalculateDelta(start, end, delta): return start + (end - start) * delta - def OUT_QUAD(self, t, b, c, d): + @staticmethod + def OUT_QUAD(t, b, c, d): t = float(t) b = float(b) c = float(c) diff --git a/gui/statsPane.py b/gui/statsPane.py index f1ea90e22..6aaf277f5 100644 --- a/gui/statsPane.py +++ b/gui/statsPane.py @@ -93,7 +93,8 @@ class StatsPane(wx.Panel): self.mainFrame = gui.mainFrame.MainFrame.getInstance() self.mainFrame.Bind(GE.FIT_CHANGED, self.fitChanged) - def contextHandler(self, contentPanel): + @staticmethod + def contextHandler(contentPanel): viewName = contentPanel.viewName def handler(event): diff --git a/service/attribute.py b/service/attribute.py index 68b998f07..5b010bcc5 100644 --- a/service/attribute.py +++ b/service/attribute.py @@ -30,7 +30,8 @@ class Attribute(object): return cls.instance - def getAttributeInfo(self, identity): + @staticmethod + def getAttributeInfo(identity): if isinstance(identity, (int, basestring)): info = eos.db.getAttributeInfo(identity, eager=("icon", "unit")) elif isinstance(identity, (int, float)): diff --git a/service/character.py b/service/character.py index c5bbc4d02..830eb5d57 100644 --- a/service/character.py +++ b/service/character.py @@ -190,33 +190,40 @@ class Character(object): return prettydata - def backupSkills(self, path, saveFmt, activeFit, callback): + @staticmethod + def backupSkills(path, saveFmt, activeFit, callback): thread = SkillBackupThread(path, saveFmt, activeFit, callback) thread.start() - def importCharacter(self, path, callback): + @staticmethod + def importCharacter(path, callback): thread = CharacterImportThread(path, callback) thread.start() - def all0(self): + @staticmethod + def all0(): return es_Character.getAll0() def all0ID(self): return self.all0().ID - def all5(self): + @staticmethod + def all5(): return es_Character.getAll5() def all5ID(self): return self.all5().ID - def getAlphaCloneList(self): + @staticmethod + def getAlphaCloneList(): return eos.db.getAlphaCloneList() - def getCharacterList(self): + @staticmethod + def getCharacterList(): return eos.db.getCharacterList() - def getCharacter(self, charID): + @staticmethod + def getCharacter(charID): char = eos.db.getCharacter(charID) return char @@ -227,7 +234,8 @@ class Character(object): char = eos.db.getCharacter(charID) char.saveLevels() - def saveCharacterAs(self, charID, newName): + @staticmethod + def saveCharacterAs(charID, newName): """Save edited skills as a new character""" char = eos.db.getCharacter(charID) newChar = copy.deepcopy(char) @@ -237,12 +245,14 @@ class Character(object): # revert old char char.revertLevels() - def revertCharacter(self, charID): + @staticmethod + def revertCharacter(charID): """Rollback edited skills""" char = eos.db.getCharacter(charID) char.revertLevels() - def getSkillGroups(self): + @staticmethod + def getSkillGroups(): cat = eos.db.getCategory(16) groups = [] for grp in cat.groups: @@ -250,7 +260,8 @@ class Character(object): groups.append((grp.ID, grp.name)) return groups - def getSkills(self, groupID): + @staticmethod + def getSkills(groupID): group = eos.db.getGroup(groupID) skills = [] for skill in group.items: @@ -258,47 +269,58 @@ class Character(object): skills.append((skill.ID, skill.name)) return skills - def setAlphaClone(self, char, cloneID): + @staticmethod + def setAlphaClone(char, cloneID): char.alphaCloneID = cloneID eos.db.commit() - def getSkillDescription(self, itemID): + @staticmethod + def getSkillDescription(itemID): return eos.db.getItem(itemID).description - def getGroupDescription(self, groupID): + @staticmethod + def getGroupDescription(groupID): return eos.db.getMarketGroup(groupID).description - def getSkillLevel(self, charID, skillID): + @staticmethod + def getSkillLevel(charID, skillID): skill = eos.db.getCharacter(charID).getSkill(skillID) return skill.level if skill.learned else "Not learned", skill.isDirty - def getDirtySkills(self, charID): + @staticmethod + def getDirtySkills(charID): return eos.db.getCharacter(charID).dirtySkills - def getCharName(self, charID): + @staticmethod + def getCharName(charID): return eos.db.getCharacter(charID).name - def new(self, name="New Character"): + @staticmethod + def new(name="New Character"): char = es_Character(name) eos.db.save(char) return char - def rename(self, char, newName): + @staticmethod + def rename(char, newName): if char.name in ("All 0", "All 5"): logger.info("Cannot rename built in characters.") else: char.name = newName eos.db.commit() - def copy(self, char): + @staticmethod + def copy(char): newChar = copy.deepcopy(char) eos.db.save(newChar) return newChar - def delete(self, char): + @staticmethod + def delete(char): eos.db.remove(char) - def getApiDetails(self, charID): + @staticmethod + def getApiDetails(charID): char = eos.db.getCharacter(charID) if char.chars is not None: chars = json.loads(char.chars) @@ -310,7 +332,8 @@ class Character(object): id_, key, default, _ = self.getApiDetails(charID) return id_ is not "" and key is not "" and default is not "" - def apiCharList(self, charID, userID, apiKey): + @staticmethod + def apiCharList(charID, userID, apiKey): char = eos.db.getCharacter(charID) char.apiID = userID @@ -324,7 +347,8 @@ class Character(object): char.chars = json.dumps(charList) return charList - def apiFetch(self, charID, charName): + @staticmethod + def apiFetch(charID, charName): dbChar = eos.db.getCharacter(charID) dbChar.defaultChar = charName @@ -344,12 +368,14 @@ class Character(object): dbChar.apiUpdateCharSheet(sheet.skills) eos.db.commit() - def apiUpdateCharSheet(self, charID, skills): + @staticmethod + def apiUpdateCharSheet(charID, skills): char = eos.db.getCharacter(charID) char.apiUpdateCharSheet(skills) eos.db.commit() - def changeLevel(self, charID, skillID, level, persist=False): + @staticmethod + def changeLevel(charID, skillID, level, persist=False): char = eos.db.getCharacter(charID) skill = char.getSkill(skillID) if isinstance(level, basestring) or level > 5 or level < 0: @@ -362,17 +388,20 @@ class Character(object): eos.db.commit() - def revertLevel(self, charID, skillID): + @staticmethod + def revertLevel(charID, skillID): char = eos.db.getCharacter(charID) skill = char.getSkill(skillID) skill.revert() - def saveSkill(self, charID, skillID): + @staticmethod + def saveSkill(charID, skillID): char = eos.db.getCharacter(charID) skill = char.getSkill(skillID) skill.saveLevel() - def addImplant(self, charID, itemID): + @staticmethod + def addImplant(charID, itemID): char = eos.db.getCharacter(charID) if char.ro: logger.error("Trying to add implant to read-only character") @@ -382,12 +411,14 @@ class Character(object): char.implants.append(implant) eos.db.commit() - def removeImplant(self, charID, implant): + @staticmethod + def removeImplant(charID, implant): char = eos.db.getCharacter(charID) char.implants.remove(implant) eos.db.commit() - def getImplants(self, charID): + @staticmethod + def getImplants(charID): char = eos.db.getCharacter(charID) return char.implants diff --git a/service/damagePattern.py b/service/damagePattern.py index 21536e53e..5a169734c 100644 --- a/service/damagePattern.py +++ b/service/damagePattern.py @@ -37,31 +37,38 @@ class DamagePattern(object): return cls.instance - def getDamagePatternList(self): + @staticmethod + def getDamagePatternList(): return eos.db.getDamagePatternList() - def getDamagePattern(self, name): + @staticmethod + def getDamagePattern(name): return eos.db.getDamagePattern(name) - def newPattern(self, name): + @staticmethod + def newPattern(name): p = es_DamagePattern(0, 0, 0, 0) p.name = name eos.db.save(p) return p - def renamePattern(self, p, newName): + @staticmethod + def renamePattern(p, newName): p.name = newName eos.db.save(p) - def deletePattern(self, p): + @staticmethod + def deletePattern(p): eos.db.remove(p) - def copyPattern(self, p): + @staticmethod + def copyPattern(p): newP = copy.deepcopy(p) eos.db.save(newP) return newP - def saveChanges(self, p): + @staticmethod + def saveChanges(p): eos.db.save(p) def importPatterns(self, text): diff --git a/service/fit.py b/service/fit.py index bafbfea0d..dec2ae647 100644 --- a/service/fit.py +++ b/service/fit.py @@ -75,11 +75,13 @@ class Fit(object): self.serviceFittingOptions = SettingsProvider.getInstance().getSettings( "pyfaServiceFittingOptions", serviceFittingDefaultOptions) - def getAllFits(self): + @staticmethod + def getAllFits(): fits = eos.db.getFitList() return fits - def getFitsWithShip(self, shipID): + @staticmethod + def getFitsWithShip(shipID): """ Lists fits of shipID, used with shipBrowser """ fits = eos.db.getFitsWithShip(shipID) names = [] @@ -88,7 +90,8 @@ class Fit(object): return names - def getBoosterFits(self): + @staticmethod + def getBoosterFits(): """ Lists fits flagged as booster """ fits = eos.db.getBoosterFits() names = [] @@ -97,14 +100,17 @@ class Fit(object): return names - def countAllFits(self): + @staticmethod + def countAllFits(): return eos.db.countAllFits() - def countFitsWithShip(self, stuff): + @staticmethod + def countFitsWithShip(stuff): count = eos.db.countFitsWithShip(stuff) return count - def getModule(self, fitID, pos): + @staticmethod + def getModule(fitID, pos): fit = eos.db.getFit(fitID) return fit.modules[pos] @@ -123,17 +129,20 @@ class Fit(object): self.recalc(fit) return fit.ID - def toggleBoostFit(self, fitID): + @staticmethod + def toggleBoostFit(fitID): fit = eos.db.getFit(fitID) fit.booster = not fit.booster eos.db.commit() - def renameFit(self, fitID, newName): + @staticmethod + def renameFit(fitID, newName): fit = eos.db.getFit(fitID) fit.name = newName eos.db.commit() - def deleteFit(self, fitID): + @staticmethod + def deleteFit(fitID): fit = eos.db.getFit(fitID) eos.db.remove(fit) @@ -144,13 +153,15 @@ class Fit(object): if projection.victim_fit in eos.db.saveddata_session: # GH issue #359 eos.db.saveddata_session.refresh(projection.victim_fit) - def copyFit(self, fitID): + @staticmethod + def copyFit(fitID): fit = eos.db.getFit(fitID) newFit = copy.deepcopy(fit) eos.db.save(newFit) return newFit.ID - def clearFit(self, fitID): + @staticmethod + def clearFit(fitID): if fitID is None: return None @@ -214,7 +225,8 @@ class Fit(object): fit.inited = True return fit - def searchFits(self, name): + @staticmethod + def searchFits(name): results = eos.db.searchFits(name) fits = [] for fit in results: @@ -539,7 +551,8 @@ class Fit(object): eos.db.commit() self.recalc(fit) - def swapModules(self, fitID, src, dst): + @staticmethod + def swapModules(fitID, src, dst): fit = eos.db.getFit(fitID) # Gather modules srcMod = fit.modules[src] @@ -720,7 +733,8 @@ class Fit(object): self.recalc(fit) return True - def splitDrones(self, fit, d, amount, l): + @staticmethod + def splitDrones(fit, d, amount, l): total = d.amount active = d.amountActive > 0 d.amount = amount @@ -824,7 +838,8 @@ class Fit(object): fit.character = self.character = eos.db.getCharacter(charID) self.recalc(fit) - def isAmmo(self, itemID): + @staticmethod + def isAmmo(itemID): return eos.db.getItem(itemID).category.name == "Charge" def setAmmo(self, fitID, ammoID, modules): @@ -840,7 +855,8 @@ class Fit(object): self.recalc(fit) - def getTargetResists(self, fitID): + @staticmethod + def getTargetResists(fitID): if fitID is None: return @@ -857,7 +873,8 @@ class Fit(object): self.recalc(fit) - def getDamagePattern(self, fitID): + @staticmethod + def getDamagePattern(fitID): if fitID is None: return diff --git a/service/implantSet.py b/service/implantSet.py index f1da65aed..8d86c816d 100644 --- a/service/implantSet.py +++ b/service/implantSet.py @@ -39,44 +39,54 @@ class ImplantSets(object): return cls.instance - def getImplantSetList(self): + @staticmethod + def getImplantSetList(): return eos.db.getImplantSetList(None) - def getImplantSet(self, name): + @staticmethod + def getImplantSet(name): return eos.db.getImplantSet(name) - def getImplants(self, setID): + @staticmethod + def getImplants(setID): return eos.db.getImplantSet(setID).implants - def addImplant(self, setID, itemID): + @staticmethod + def addImplant(setID, itemID): implant_set = eos.db.getImplantSet(setID) implant = es_Implant(eos.db.getItem(itemID)) implant_set.implants.append(implant) eos.db.commit() - def removeImplant(self, setID, implant): + @staticmethod + def removeImplant(setID, implant): eos.db.getImplantSet(setID).implants.remove(implant) eos.db.commit() - def newSet(self, name): + @staticmethod + def newSet(name): implant_set = es_ImplantSet() implant_set.name = name eos.db.save(implant_set) return implant_set - def renameSet(self, implant_set, newName): + @staticmethod + def renameSet(implant_set, newName): implant_set.name = newName eos.db.save(implant_set) - def deleteSet(self, implant_set): + @staticmethod + def deleteSet(implant_set): eos.db.remove(implant_set) - def copySet(self, implant_set): + @staticmethod + def copySet(implant_set): newS = copy.deepcopy(implant_set) eos.db.save(newS) return newS - def saveChanges(self, implant_set): + @staticmethod + def saveChanges(implant_set): eos.db.save(implant_set) def importSets(self, text): diff --git a/service/market.py b/service/market.py index 55ddc3ec7..8a2abb107 100644 --- a/service/market.py +++ b/service/market.py @@ -410,7 +410,8 @@ class Market(object): cls.instance = Market() return cls.instance - def __makeRevDict(self, orig): + @staticmethod + def __makeRevDict(orig): """Creates reverse dictionary""" rev = {} for item, value in orig.items(): @@ -419,7 +420,8 @@ class Market(object): rev[value].add(item) return rev - def getItem(self, identity, *args, **kwargs): + @staticmethod + def getItem(identity, *args, **kwargs): """Get item by its ID or name""" try: if isinstance(identity, types_Item): @@ -461,7 +463,8 @@ class Market(object): else: raise TypeError("Need Group object, integer, float or string as argument") - def getCategory(self, identity, *args, **kwargs): + @staticmethod + def getCategory(identity, *args, **kwargs): """Get category by its ID or name""" if isinstance(identity, types_Category): category = identity @@ -474,7 +477,8 @@ class Market(object): raise TypeError("Need Category object, integer, float or string as argument") return category - def getMetaGroup(self, identity, *args, **kwargs): + @staticmethod + def getMetaGroup(identity, *args, **kwargs): """Get meta group by its ID or name""" if isinstance(identity, types_MetaGroup): metaGroup = identity @@ -487,7 +491,8 @@ class Market(object): raise TypeError("Need MetaGroup object, integer, float or string as argument") return metaGroup - def getMarketGroup(self, identity, *args, **kwargs): + @staticmethod + def getMarketGroup(identity, *args, **kwargs): """Get market group by its ID""" if isinstance(identity, types_MarketGroup): marketGroup = identity @@ -605,7 +610,8 @@ class Market(object): return groups - def getMarketGroupChildren(self, mg): + @staticmethod + def getMarketGroupChildren(mg): """Get the children marketGroups of marketGroup.""" children = set() for child in mg.children: @@ -762,7 +768,8 @@ class Market(object): """Find items according to given text pattern""" self.searchWorkerThread.scheduleSearch(name, callback, filterOn) - def getItemsWithOverrides(self): + @staticmethod + def getItemsWithOverrides(): overrides = eos.db.getAllOverrides() items = set() for x in overrides: @@ -773,7 +780,8 @@ class Market(object): items.add(x.item) return list(items) - def directAttrRequest(self, items, attribs): + @staticmethod + def directAttrRequest(items, attribs): try: itemIDs = tuple(map(lambda i: i.ID, items)) except TypeError: diff --git a/service/port.py b/service/port.py index b76068bcb..5a6b53fb5 100644 --- a/service/port.py +++ b/service/port.py @@ -81,15 +81,18 @@ class Port(object): return cls.instance - def backupFits(self, path, callback): + @staticmethod + def backupFits(path, callback): thread = FitBackupThread(path, callback) thread.start() - def importFitsThreaded(self, paths, callback): + @staticmethod + def importFitsThreaded(paths, callback): thread = FitImportThread(paths, callback) thread.start() - def importFitFromFiles(self, paths, callback=None): + @staticmethod + def importFitFromFiles(paths, callback=None): """ Imports fits from file(s). First processes all provided paths and stores assembled fits into a list. This allows us to call back to the GUI as @@ -185,7 +188,8 @@ class Port(object): return True, fits - def importFitFromBuffer(self, bufferStr, activeFit=None): + @staticmethod + def importFitFromBuffer(bufferStr, activeFit=None): sFit = svcFit.getInstance() _, fits = Port.importAuto(bufferStr, activeFit=activeFit) for fit in fits: diff --git a/service/pycrest/eve.py b/service/pycrest/eve.py index cd5a82f8c..56b353ad4 100644 --- a/service/pycrest/eve.py +++ b/service/pycrest/eve.py @@ -161,7 +161,8 @@ class APIConnection(object): return ret - def _get_expires(self, response): + @staticmethod + def _get_expires(response): if 'Cache-Control' not in response.headers: return 0 if any([s in response.headers['Cache-Control'] for s in ['no-cache', 'no-store']]): diff --git a/service/targetResists.py b/service/targetResists.py index 2a4863c5d..06df8c8c6 100644 --- a/service/targetResists.py +++ b/service/targetResists.py @@ -37,31 +37,38 @@ class TargetResists(object): return cls.instance - def getTargetResistsList(self): + @staticmethod + def getTargetResistsList(): return db.getTargetResistsList() - def getTargetResists(self, name): + @staticmethod + def getTargetResists(name): return db.getTargetResists(name) - def newPattern(self, name): + @staticmethod + def newPattern(name): p = es_TargetResists(0.0, 0.0, 0.0, 0.0) p.name = name db.save(p) return p - def renamePattern(self, p, newName): + @staticmethod + def renamePattern(p, newName): p.name = newName db.save(p) - def deletePattern(self, p): + @staticmethod + def deletePattern(p): db.remove(p) - def copyPattern(self, p): + @staticmethod + def copyPattern(p): newP = copy.deepcopy(p) db.save(newP) return newP - def saveChanges(self, p): + @staticmethod + def saveChanges(p): db.save(p) def importPatterns(self, text): diff --git a/service/update.py b/service/update.py index 9ae296ad7..969c78432 100644 --- a/service/update.py +++ b/service/update.py @@ -85,14 +85,16 @@ class CheckUpdateThread(threading.Thread): except: pass - def versiontuple(self, v): + @staticmethod + def versiontuple(v): return tuple(map(int, (v.split(".")))) class Update(object): instance = None - def CheckUpdate(self, callback): + @staticmethod + def CheckUpdate(callback): thread = CheckUpdateThread(callback) thread.start()