Make modules static if they do not use self.

This commit is contained in:
Ebag333
2017-02-09 00:04:41 -08:00
parent 72633825cf
commit 11d7f9d029
31 changed files with 266 additions and 133 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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")

View File

@@ -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

View File

@@ -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")

View File

@@ -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,

View File

@@ -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("")

View File

@@ -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"

View File

@@ -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)

View File

@@ -426,7 +426,8 @@ class PFGaugePref(PreferenceView):
self.SetColours()
event.Skip()
def OnOk(self, event):
@staticmethod
def OnOk(event):
# Apply New Settings
event.Skip()

View File

@@ -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

View File

@@ -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):

View File

@@ -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)

View File

@@ -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
'''

View File

@@ -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

View File

@@ -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

View File

@@ -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):

View File

@@ -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}.

View File

@@ -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):

View File

@@ -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)

View File

@@ -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):

View File

@@ -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)):

View File

@@ -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

View File

@@ -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):

View File

@@ -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

View File

@@ -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):

View File

@@ -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:

View File

@@ -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:

View File

@@ -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']]):

View File

@@ -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):

View File

@@ -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()