Created
February 12, 2019 10:54
-
-
Save DarkFenX/440b66a1243140d810caa99ee384034e to your computer and use it in GitHub Desktop.
Patch to add "loaded charges" option to ESI export
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/gui/copySelectDialog.py b/gui/copySelectDialog.py | |
index 49ebb6ac..b8225f45 100644 | |
--- a/gui/copySelectDialog.py | |
+++ b/gui/copySelectDialog.py | |
@@ -24,6 +24,7 @@ from collections import OrderedDict | |
import wx | |
from service.port.eft import EFT_OPTIONS | |
+from service.port.esi import ESI_OPTIONS | |
from service.port.multibuy import MULTIBUY_OPTIONS | |
from service.settings import SettingsProvider | |
@@ -44,7 +45,7 @@ class CopySelectDialog(wx.Dialog): | |
self.copyFormats = OrderedDict(( | |
("EFT", (CopySelectDialog.copyFormatEft, EFT_OPTIONS)), | |
("MultiBuy", (CopySelectDialog.copyFormatMultiBuy, MULTIBUY_OPTIONS)), | |
- ("ESI", (CopySelectDialog.copyFormatEsi, None)), | |
+ ("ESI", (CopySelectDialog.copyFormatEsi, ESI_OPTIONS)), | |
("EFS", (CopySelectDialog.copyFormatEfs, None)), | |
# ("XML", (CopySelectDialog.copyFormatXml, None)), | |
# ("DNA", (CopySelectDialog.copyFormatDna, None)), | |
diff --git a/gui/mainFrame.py b/gui/mainFrame.py | |
index a37f1afd..b638bedf 100644 | |
--- a/gui/mainFrame.py | |
+++ b/gui/mainFrame.py | |
@@ -709,7 +709,7 @@ class MainFrame(wx.Frame): | |
def clipboardEsi(self, options): | |
fit = db_getFit(self.getActiveFit()) | |
- toClipboard(Port.exportESI(fit)) | |
+ toClipboard(Port.exportESI(fit, options)) | |
def clipboardXml(self, options): | |
fit = db_getFit(self.getActiveFit()) | |
@@ -747,7 +747,7 @@ class MainFrame(wx.Frame): | |
CopySelectDialog.copyFormatEfs: self.clipboardEfs} | |
dlg = CopySelectDialog(self) | |
btnPressed = dlg.ShowModal() | |
- | |
+ | |
if btnPressed == wx.ID_OK: | |
selected = dlg.GetSelected() | |
options = dlg.GetOptions() | |
diff --git a/service/port/esi.py b/service/port/esi.py | |
index 8268f23f..ad0d95ab 100644 | |
--- a/service/port/esi.py | |
+++ b/service/port/esi.py | |
@@ -20,6 +20,7 @@ | |
import collections | |
import json | |
+from enum import Enum | |
from logbook import Logger | |
@@ -38,6 +39,15 @@ class ESIExportException(Exception): | |
pass | |
+class Options(Enum): | |
+ LOADED_CHARGES = 1 | |
+ | |
+ | |
+ESI_OPTIONS = ( | |
+ (Options.LOADED_CHARGES.value, 'Loaded Charges', 'Export charges loaded into modules', True), | |
+) | |
+ | |
+ | |
pyfalog = Logger(__name__) | |
INV_FLAGS = { | |
@@ -54,7 +64,7 @@ INV_FLAG_DRONEBAY = 87 | |
INV_FLAG_FIGHTER = 158 | |
-def exportESI(ofit): | |
+def exportESI(ofit, options): | |
# A few notes: | |
# max fit name length is 50 characters | |
# Most keys are created simply because they are required, but bogus data is okay | |
@@ -97,7 +107,7 @@ def exportESI(ofit): | |
item['type_id'] = module.item.ID | |
fit['items'].append(item) | |
- if module.charge: | |
+ if module.charge and options[Options.LOADED_CHARGES.value]: | |
if module.chargeID not in charges: | |
charges[module.chargeID] = 0 | |
# `or 1` because some charges (ie scripts) are without qty | |
diff --git a/service/port/port.py b/service/port/port.py | |
index 40999181..fee3d614 100644 | |
--- a/service/port/port.py | |
+++ b/service/port/port.py | |
@@ -270,8 +270,8 @@ class Port(object): | |
return importESI(string) | |
@staticmethod | |
- def exportESI(fit): | |
- return exportESI(fit) | |
+ def exportESI(fit, options): | |
+ return exportESI(fit, options) | |
# XML-related methods | |
@staticmethod |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment