Fixed a rare occurance where an attribute from stats can be None, do the sanity check first before throwing the value to shorten func; cleaned up some commented lines

This commit is contained in:
HomeWorld
2010-09-03 10:18:09 +03:00
parent 59a27f96e7
commit 3265b1db8a

View File

@@ -94,12 +94,9 @@ class StatsPane(wx.Panel):
for labelName, value, rounding in stats:
label = getattr(self, labelName)
label.SetLabel(shorten(value() if fit is not None else 0, rounding))
# resMax = (("cpuTotal", lambda: fit.ship.getModifiedItemAttr("cpuOutput")),
# ("pgTotal", lambda: fit.ship.getModifiedItemAttr("powerOutput")),
# ("droneBayTotal", lambda: fit.ship.getModifiedItemAttr("droneCapacity")),
# ("droneBandwidthTotal", lambda: fit.ship.getModifiedItemAttr("droneBandwidth")))
value = value() if fit is not None else 0
value = value if value is not None else 0
label.SetLabel(shorten(value, rounding))
# cap stuff
capState = fit.capState if fit is not None else 0