Add an option not to export charges to ESI
This commit is contained in:
@@ -177,7 +177,7 @@ class CopySelectDialog(wx.Dialog):
|
|||||||
|
|
||||||
def exportEsi(self, options, callback):
|
def exportEsi(self, options, callback):
|
||||||
fit = getFit(self.mainFrame.getActiveFit())
|
fit = getFit(self.mainFrame.getActiveFit())
|
||||||
Port.exportESI(fit, callback)
|
Port.exportESI(fit, True, callback)
|
||||||
|
|
||||||
def exportXml(self, options, callback):
|
def exportXml(self, options, callback):
|
||||||
fit = getFit(self.mainFrame.getActiveFit())
|
fit = getFit(self.mainFrame.getActiveFit())
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ from service.esiAccess import APIException
|
|||||||
from service.fit import Fit
|
from service.fit import Fit
|
||||||
from service.port import Port
|
from service.port import Port
|
||||||
from service.port.esi import ESIExportException
|
from service.port.esi import ESIExportException
|
||||||
|
from service.settings import EsiSettings
|
||||||
|
|
||||||
|
|
||||||
pyfalog = Logger(__name__)
|
pyfalog = Logger(__name__)
|
||||||
@@ -207,7 +208,7 @@ class ExportToEve(AuxiliaryFrame):
|
|||||||
def __init__(self, parent):
|
def __init__(self, parent):
|
||||||
super().__init__(
|
super().__init__(
|
||||||
parent, id=wx.ID_ANY, title="Export fit to EVE", pos=wx.DefaultPosition,
|
parent, id=wx.ID_ANY, title="Export fit to EVE", pos=wx.DefaultPosition,
|
||||||
size=wx.Size(400, 120) if "wxGTK" in wx.PlatformInfo else wx.Size(350, 100), resizeable=True)
|
size=wx.Size(400, 140) if "wxGTK" in wx.PlatformInfo else wx.Size(350, 115), resizeable=True)
|
||||||
|
|
||||||
self.mainFrame = parent
|
self.mainFrame = parent
|
||||||
|
|
||||||
@@ -224,6 +225,11 @@ class ExportToEve(AuxiliaryFrame):
|
|||||||
|
|
||||||
mainSizer.Add(hSizer, 0, wx.EXPAND, 5)
|
mainSizer.Add(hSizer, 0, wx.EXPAND, 5)
|
||||||
|
|
||||||
|
self.exportChargesCb = wx.CheckBox(self, wx.ID_ANY, 'Export Charges', wx.DefaultPosition, wx.DefaultSize, 0)
|
||||||
|
self.exportChargesCb.SetValue(EsiSettings.getInstance().get('exportCharges'))
|
||||||
|
self.exportChargesCb.Bind(wx.EVT_CHECKBOX, self.OnChargeExportChange)
|
||||||
|
mainSizer.Add(self.exportChargesCb, 0, 0, 5)
|
||||||
|
|
||||||
self.exportBtn.Bind(wx.EVT_BUTTON, self.exportFitting)
|
self.exportBtn.Bind(wx.EVT_BUTTON, self.exportFitting)
|
||||||
|
|
||||||
self.statusbar = wx.StatusBar(self)
|
self.statusbar = wx.StatusBar(self)
|
||||||
@@ -239,6 +245,10 @@ class ExportToEve(AuxiliaryFrame):
|
|||||||
|
|
||||||
self.Center(wx.BOTH)
|
self.Center(wx.BOTH)
|
||||||
|
|
||||||
|
def OnChargeExportChange(self, event):
|
||||||
|
EsiSettings.getInstance().set('exportCharges', self.exportChargesCb.GetValue())
|
||||||
|
event.Skip()
|
||||||
|
|
||||||
def updateCharList(self):
|
def updateCharList(self):
|
||||||
sEsi = Esi.getInstance()
|
sEsi = Esi.getInstance()
|
||||||
chars = sEsi.getSsoCharacters()
|
chars = sEsi.getSsoCharacters()
|
||||||
@@ -274,8 +284,9 @@ class ExportToEve(AuxiliaryFrame):
|
|||||||
sEsi = Esi.getInstance()
|
sEsi = Esi.getInstance()
|
||||||
|
|
||||||
sFit = Fit.getInstance()
|
sFit = Fit.getInstance()
|
||||||
|
exportCharges = self.exportChargesCb.GetValue()
|
||||||
try:
|
try:
|
||||||
data = sPort.exportESI(sFit.getFit(fitID))
|
data = sPort.exportESI(sFit.getFit(fitID), exportCharges)
|
||||||
except ESIExportException as e:
|
except ESIExportException as e:
|
||||||
msg = str(e)
|
msg = str(e)
|
||||||
if not msg:
|
if not msg:
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ INV_FLAG_DRONEBAY = 87
|
|||||||
INV_FLAG_FIGHTER = 158
|
INV_FLAG_FIGHTER = 158
|
||||||
|
|
||||||
|
|
||||||
def exportESI(ofit, callback):
|
def exportESI(ofit, exportCharges, callback):
|
||||||
# A few notes:
|
# A few notes:
|
||||||
# max fit name length is 50 characters
|
# max fit name length is 50 characters
|
||||||
# Most keys are created simply because they are required, but bogus data is okay
|
# Most keys are created simply because they are required, but bogus data is okay
|
||||||
@@ -99,7 +99,7 @@ def exportESI(ofit, callback):
|
|||||||
item['type_id'] = module.item.ID
|
item['type_id'] = module.item.ID
|
||||||
fit['items'].append(item)
|
fit['items'].append(item)
|
||||||
|
|
||||||
if module.charge:
|
if module.charge and exportCharges:
|
||||||
if module.chargeID not in charges:
|
if module.chargeID not in charges:
|
||||||
charges[module.chargeID] = 0
|
charges[module.chargeID] = 0
|
||||||
# `or 1` because some charges (ie scripts) are without qty
|
# `or 1` because some charges (ie scripts) are without qty
|
||||||
|
|||||||
@@ -314,8 +314,8 @@ class Port:
|
|||||||
return importESI(string)
|
return importESI(string)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def exportESI(fit, callback=None):
|
def exportESI(fit, exportCharges, callback=None):
|
||||||
return exportESI(fit, callback=callback)
|
return exportESI(fit, exportCharges, callback=callback)
|
||||||
|
|
||||||
# XML-related methods
|
# XML-related methods
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|||||||
@@ -370,7 +370,8 @@ class EsiSettings:
|
|||||||
"loginMode": 0,
|
"loginMode": 0,
|
||||||
"clientID": "",
|
"clientID": "",
|
||||||
"clientSecret": "",
|
"clientSecret": "",
|
||||||
"timeout": 60}
|
"timeout": 60,
|
||||||
|
"exportCharges": True}
|
||||||
|
|
||||||
self.settings = SettingsProvider.getInstance().getSettings(
|
self.settings = SettingsProvider.getInstance().getSettings(
|
||||||
"pyfaServiceEsiSettings",
|
"pyfaServiceEsiSettings",
|
||||||
|
|||||||
Reference in New Issue
Block a user