Instead of passing fitID to export service, pass the fit itself. Fixes #122

This commit is contained in:
blitzmann
2014-06-11 18:56:40 -04:00
parent 23044b5cdb
commit 3c5538109d
2 changed files with 14 additions and 20 deletions

View File

@@ -222,7 +222,7 @@ class Fit(object):
def getFit(self, fitID, projected = False):
''' Gets fit from database, and populates fleet data.
Projected is a recursion flag that is set to reduce recursions into projected fits
'''
if fitID is None:
@@ -237,13 +237,13 @@ class Fit(object):
fit.fleet = None
else:
fit.fleet = f
if not projected:
if not projected:
for fitP in fit.projectedFits:
self.getFit(fitP.ID, projected = True)
self.recalc(fit, withBoosters=True)
fit.fill()
eos.db.commit()
fit.inited = True
return fit
@@ -718,13 +718,16 @@ class Fit(object):
self.recalc(fit)
def exportFit(self, fitID):
return Port.exportEft(fitID)
fit = eos.db.getFit(fitID)
return Port.exportEft(fit)
def exportEftImps(self, fitID):
return Port.exportEftImps(fitID)
fit = eos.db.getFit(fitID)
return Port.exportEftImps(fit)
def exportDna(self, fitID):
return Port.exportDna(fitID)
fit = eos.db.getFit(fitID)
return Port.exportDna(fit)
def exportXml(self, *fitIDs):
fits = map(lambda fitID: eos.db.getFit(fitID), fitIDs)

View File

@@ -562,10 +562,7 @@ class Port(object):
return fits
@staticmethod
def exportEft(fitID):
sFit = service.Fit.getInstance()
fit = sFit.getFit(fitID)
def exportEft(fit):
offineSuffix = " /OFFLINE"
export = "[%s, %s]\n" % (fit.ship.item.name, fit.name)
stuff = {}
@@ -602,11 +599,8 @@ class Port(object):
return export
@classmethod
def exportEftImps(cls, fitID):
export = cls.exportEft(fitID)
sFit = service.Fit.getInstance()
fit = sFit.getFit(fitID)
def exportEftImps(cls, fit):
export = cls.exportEft(fit)
if len(fit.implants) > 0:
export += "\n\n\n"
@@ -619,10 +613,7 @@ class Port(object):
return export
@staticmethod
def exportDna(fitID):
sFit = service.Fit.getInstance()
fit = sFit.getFit(fitID)
def exportDna(fit):
dna = str(fit.shipID)
mods = OrderedDict()
charges = OrderedDict()