diff --git a/eos/config.py b/eos/config.py index cf5b2e937..38371e299 100644 --- a/eos/config.py +++ b/eos/config.py @@ -16,4 +16,3 @@ settings = { # Autodetect path, only change if the autodetection bugs out. path = dirname(unicode(__file__, sys.getfilesystemencoding())) - diff --git a/eos/effects/tractorbeamcan.py b/eos/effects/tractorbeamcan.py index c865b1c22..2c7f8eae3 100644 --- a/eos/effects/tractorbeamcan.py +++ b/eos/effects/tractorbeamcan.py @@ -2,8 +2,9 @@ # # Used by: # Modules from group: Tractor Beam (4 of 4) -type = "active" from eos.config import settings +type = "active" + def handler(fit, module, context): print settings['setting1'] diff --git a/eos/modifiedAttributeDict.py b/eos/modifiedAttributeDict.py index 757d8a3d1..bc8dfd9a1 100644 --- a/eos/modifiedAttributeDict.py +++ b/eos/modifiedAttributeDict.py @@ -26,17 +26,23 @@ cappingAttrKeyCache = {} class ItemAttrShortcut(object): def getModifiedItemAttr(self, key, default=None): - if key in self.itemModifiedAttributes: - return self.itemModifiedAttributes[key] - else: + try: + if key in self.itemModifiedAttributes: + return self.itemModifiedAttributes[key] + else: + return default + except AttributeError: return default class ChargeAttrShortcut(object): def getModifiedChargeAttr(self, key, default=None): - if key in self.chargeModifiedAttributes: - return self.chargeModifiedAttributes[key] - else: + try: + if key in self.chargeModifiedAttributes: + return self.chargeModifiedAttributes[key] + else: + return default + except AttributeError: return default diff --git a/gui/builtinStatsViews/capacitorViewFull.py b/gui/builtinStatsViews/capacitorViewFull.py index f85b35e4c..b30265741 100644 --- a/gui/builtinStatsViews/capacitorViewFull.py +++ b/gui/builtinStatsViews/capacitorViewFull.py @@ -114,6 +114,11 @@ class CapacitorViewFull(StatsView): ("label%sCapacitorRecharge", lambda: fit.capRecharge, 3, 0, 0), ("label%sCapacitorDischarge", lambda: fit.capUsed, 3, 0, 0), ) + if fit is None: + # Set default if fit is empty + neut_resist = 0 + else: + neut_resist = fit.ship.getModifiedItemAttr("energyWarfareResistance", 0) panel = "Full" for labelName, value, prec, lowest, highest in stats: @@ -127,6 +132,12 @@ class CapacitorViewFull(StatsView): label.SetLabel(formatAmount(value, prec, lowest, highest)) label.SetToolTip(wx.ToolTip("%.1f" % value)) + if labelName == "label%sCapacitorDischarge": + if neut_resist: + neut_resist = 100 - (neut_resist * 100) + label_tooltip = "Neut Resistance: {0:.0f}%".format(neut_resist) + label.SetToolTip(wx.ToolTip(label_tooltip)) + capState = fit.capState if fit is not None else 0 capStable = fit.capStable if fit is not None else False lblNameTime = "label%sCapacitorTime" diff --git a/service/port.py b/service/port.py index 3c0930810..3e923ed0f 100644 --- a/service/port.py +++ b/service/port.py @@ -816,7 +816,7 @@ class Port(object): if callback: wx.CallAfter(callback, None) # Skip fit silently if we get an exception - except Exception as e: + except Exception as e: pyfalog.error("Caught exception on fit.") pyfalog.error(e) pass diff --git a/service/settings.py b/service/settings.py index 0159bc516..5d44d4e88 100644 --- a/service/settings.py +++ b/service/settings.py @@ -437,6 +437,7 @@ class ContextMenuSettings(object): def set(self, type, value): self.ContextMenuDefaultSettings[type] = value + class EOSSettings(object): _instance = None