PEP8 cleanup

This commit is contained in:
Ebag333
2017-03-16 02:12:26 -07:00
parent 80375d1f5b
commit 63f2f85c25
2 changed files with 83 additions and 78 deletions

View File

@@ -128,9 +128,9 @@ class Fit(object):
self.__capRecharge = None self.__capRecharge = None
self.__calculatedTargets = [] self.__calculatedTargets = []
self.__remoteReps = { self.__remoteReps = {
"Armor": None, "Armor" : None,
"Shield": None, "Shield" : None,
"Hull": None, "Hull" : None,
"Capacitor": None, "Capacitor": None,
} }
self.factorReload = False self.factorReload = False
@@ -370,9 +370,11 @@ class Fit(object):
@validates("ID", "ownerID", "shipID") @validates("ID", "ownerID", "shipID")
def validator(self, key, val): def validator(self, key, val):
map = {"ID": lambda _val: isinstance(_val, int), map = {
"ownerID": lambda _val: isinstance(_val, int) or _val is None, "ID" : lambda _val: isinstance(_val, int),
"shipID": lambda _val: isinstance(_val, int) or _val is None} "ownerID": lambda _val: isinstance(_val, int) or _val is None,
"shipID" : lambda _val: isinstance(_val, int) or _val is None
}
if not map[key](val): if not map[key](val):
raise ValueError(str(val) + " is not a valid value for " + key) raise ValueError(str(val) + " is not a valid value for " + key)
@@ -408,15 +410,15 @@ class Fit(object):
self.ship.clear() self.ship.clear()
c = chain( c = chain(
self.modules, self.modules,
self.drones, self.drones,
self.fighters, self.fighters,
self.boosters, self.boosters,
self.implants, self.implants,
self.projectedDrones, self.projectedDrones,
self.projectedModules, self.projectedModules,
self.projectedFighters, self.projectedFighters,
(self.character, self.extraAttributes), (self.character, self.extraAttributes),
) )
for stuff in c: for stuff in c:
@@ -476,11 +478,11 @@ class Fit(object):
if warfareBuffID == 11: # Shield Burst: Active Shielding: Repair Duration/Capacitor if warfareBuffID == 11: # Shield Burst: Active Shielding: Repair Duration/Capacitor
self.modules.filteredItemBoost( self.modules.filteredItemBoost(
lambda mod: mod.item.requiresSkill("Shield Operation") or mod.item.requiresSkill( lambda mod: mod.item.requiresSkill("Shield Operation") or mod.item.requiresSkill(
"Shield Emission Systems"), "capacitorNeed", value) "Shield Emission Systems"), "capacitorNeed", value)
self.modules.filteredItemBoost( self.modules.filteredItemBoost(
lambda mod: mod.item.requiresSkill("Shield Operation") or mod.item.requiresSkill( lambda mod: mod.item.requiresSkill("Shield Operation") or mod.item.requiresSkill(
"Shield Emission Systems"), "duration", value) "Shield Emission Systems"), "duration", value)
if warfareBuffID == 12: # Shield Burst: Shield Extension: Shield HP if warfareBuffID == 12: # Shield Burst: Shield Extension: Shield HP
self.ship.boostItemAttr("shieldCapacity", value, stackingPenalties=True) self.ship.boostItemAttr("shieldCapacity", value, stackingPenalties=True)
@@ -506,26 +508,26 @@ class Fit(object):
if warfareBuffID == 17: # Information Burst: Electronic Superiority: EWAR Range and Strength if warfareBuffID == 17: # Information Burst: Electronic Superiority: EWAR Range and Strength
groups = ("ECM", "Sensor Dampener", "Weapon Disruptor", "Target Painter") groups = ("ECM", "Sensor Dampener", "Weapon Disruptor", "Target Painter")
self.modules.filteredItemBoost(lambda mod: mod.item.group.name in groups, "maxRange", value, self.modules.filteredItemBoost(lambda mod: mod.item.group.name in groups, "maxRange", value,
stackingPenalties=True) stackingPenalties=True)
self.modules.filteredItemBoost(lambda mod: mod.item.group.name in groups, self.modules.filteredItemBoost(lambda mod: mod.item.group.name in groups,
"falloffEffectiveness", value, stackingPenalties=True) "falloffEffectiveness", value, stackingPenalties=True)
for scanType in ("Magnetometric", "Radar", "Ladar", "Gravimetric"): for scanType in ("Magnetometric", "Radar", "Ladar", "Gravimetric"):
self.modules.filteredItemBoost(lambda mod: mod.item.group.name == "ECM", self.modules.filteredItemBoost(lambda mod: mod.item.group.name == "ECM",
"scan%sStrengthBonus" % scanType, value, "scan%sStrengthBonus" % scanType, value,
stackingPenalties=True) stackingPenalties=True)
for attr in ("missileVelocityBonus", "explosionDelayBonus", "aoeVelocityBonus", "falloffBonus", for attr in ("missileVelocityBonus", "explosionDelayBonus", "aoeVelocityBonus", "falloffBonus",
"maxRangeBonus", "aoeCloudSizeBonus", "trackingSpeedBonus"): "maxRangeBonus", "aoeCloudSizeBonus", "trackingSpeedBonus"):
self.modules.filteredItemBoost(lambda mod: mod.item.group.name == "Weapon Disruptor", self.modules.filteredItemBoost(lambda mod: mod.item.group.name == "Weapon Disruptor",
attr, value) attr, value)
for attr in ("maxTargetRangeBonus", "scanResolutionBonus"): for attr in ("maxTargetRangeBonus", "scanResolutionBonus"):
self.modules.filteredItemBoost(lambda mod: mod.item.group.name == "Sensor Dampener", self.modules.filteredItemBoost(lambda mod: mod.item.group.name == "Sensor Dampener",
attr, value) attr, value)
self.modules.filteredItemBoost(lambda mod: mod.item.group.name == "Target Painter", self.modules.filteredItemBoost(lambda mod: mod.item.group.name == "Target Painter",
"signatureRadiusBonus", value, stackingPenalties=True) "signatureRadiusBonus", value, stackingPenalties=True)
if warfareBuffID == 18: # Information Burst: Electronic Hardening: Scan Strength if warfareBuffID == 18: # Information Burst: Electronic Hardening: Scan Strength
for scanType in ("Gravimetric", "Radar", "Ladar", "Magnetometric"): for scanType in ("Gravimetric", "Radar", "Ladar", "Magnetometric"):
@@ -544,40 +546,36 @@ class Fit(object):
if warfareBuffID == 21: # Skirmish Burst: Interdiction Maneuvers: Tackle Range if warfareBuffID == 21: # Skirmish Burst: Interdiction Maneuvers: Tackle Range
groups = ("Stasis Web", "Warp Scrambler") groups = ("Stasis Web", "Warp Scrambler")
self.modules.filteredItemBoost(lambda mod: mod.item.group.name in groups, "maxRange", value, self.modules.filteredItemBoost(lambda mod: mod.item.group.name in groups, "maxRange", value,
stackingPenalties=True) stackingPenalties=True)
if warfareBuffID == 22: # Skirmish Burst: Rapid Deployment: AB/MWD Speed Increase if warfareBuffID == 22: # Skirmish Burst: Rapid Deployment: AB/MWD Speed Increase
self.modules.filteredItemBoost( self.modules.filteredItemBoost(lambda mod: mod.item.requiresSkill("Afterburner") or
lambda mod: mod.item.requiresSkill("Afterburner") mod.item.requiresSkill("High Speed Maneuvering"),
or mod.item.requiresSkill("High Speed Maneuvering"), "speedFactor", value, stackingPenalties=True)
"speedFactor", value, stackingPenalties=True)
if warfareBuffID == 23: # Mining Burst: Mining Laser Field Enhancement: Mining/Survey Range if warfareBuffID == 23: # Mining Burst: Mining Laser Field Enhancement: Mining/Survey Range
self.modules.filteredItemBoost( self.modules.filteredItemBoost(lambda mod: mod.item.requiresSkill("Mining") or
lambda mod: mod.item.requiresSkill("Mining") or mod.item.requiresSkill("Ice Harvesting") or
mod.item.requiresSkill("Ice Harvesting") or mod.item.requiresSkill("Gas Cloud Harvesting"),
mod.item.requiresSkill("Gas Cloud Harvesting"), "maxRange", value, stackingPenalties=True)
"maxRange", value, stackingPenalties=True)
self.modules.filteredItemBoost(lambda mod: mod.item.requiresSkill("CPU Management"), self.modules.filteredItemBoost(lambda mod: mod.item.requiresSkill("CPU Management"),
"surveyScanRange", value, stackingPenalties=True) "surveyScanRange", value, stackingPenalties=True)
if warfareBuffID == 24: # Mining Burst: Mining Laser Optimization: Mining Capacitor/Duration if warfareBuffID == 24: # Mining Burst: Mining Laser Optimization: Mining Capacitor/Duration
self.modules.filteredItemBoost( self.modules.filteredItemBoost(lambda mod: mod.item.requiresSkill("Mining") or
lambda mod: mod.item.requiresSkill("Mining") or mod.item.requiresSkill("Ice Harvesting") or
mod.item.requiresSkill("Ice Harvesting") or mod.item.requiresSkill("Gas Cloud Harvesting"),
mod.item.requiresSkill("Gas Cloud Harvesting"), "capacitorNeed", value, stackingPenalties=True)
"capacitorNeed", value, stackingPenalties=True)
self.modules.filteredItemBoost( self.modules.filteredItemBoost(lambda mod: mod.item.requiresSkill("Mining") or
lambda mod: mod.item.requiresSkill("Mining") or mod.item.requiresSkill("Ice Harvesting") or
mod.item.requiresSkill("Ice Harvesting") or mod.item.requiresSkill("Gas Cloud Harvesting"),
mod.item.requiresSkill("Gas Cloud Harvesting"), "duration", value, stackingPenalties=True)
"duration", value, stackingPenalties=True)
if warfareBuffID == 25: # Mining Burst: Mining Equipment Preservation: Crystal Volatility if warfareBuffID == 25: # Mining Burst: Mining Equipment Preservation: Crystal Volatility
self.modules.filteredItemBoost(lambda mod: mod.item.requiresSkill("Mining"), self.modules.filteredItemBoost(lambda mod: mod.item.requiresSkill("Mining"),
"crystalVolatilityChance", value, stackingPenalties=True) "crystalVolatilityChance", value, stackingPenalties=True)
if warfareBuffID == 60: # Skirmish Burst: Evasive Maneuvers: Agility if warfareBuffID == 60: # Skirmish Burst: Evasive Maneuvers: Agility
self.ship.boostItemAttr("agility", value, stackingPenalties=True) self.ship.boostItemAttr("agility", value, stackingPenalties=True)
@@ -850,15 +848,17 @@ class Fit(object):
return amount return amount
slots = {Slot.LOW: "lowSlots", slots = {
Slot.MED: "medSlots", Slot.LOW : "lowSlots",
Slot.HIGH: "hiSlots", Slot.MED : "medSlots",
Slot.RIG: "rigSlots", Slot.HIGH : "hiSlots",
Slot.SUBSYSTEM: "maxSubSystems", Slot.RIG : "rigSlots",
Slot.SERVICE: "serviceSlots", Slot.SUBSYSTEM: "maxSubSystems",
Slot.F_LIGHT: "fighterLightSlots", Slot.SERVICE : "serviceSlots",
Slot.F_SUPPORT: "fighterSupportSlots", Slot.F_LIGHT : "fighterLightSlots",
Slot.F_HEAVY: "fighterHeavySlots"} Slot.F_SUPPORT: "fighterSupportSlots",
Slot.F_HEAVY : "fighterHeavySlots"
}
def getSlotsFree(self, type, countDummies=False): def getSlotsFree(self, type, countDummies=False):
if type in (Slot.MODE, Slot.SYSTEM): if type in (Slot.MODE, Slot.SYSTEM):
@@ -1007,29 +1007,35 @@ class Fit(object):
def calculateSustainableTank(self, effective=True): def calculateSustainableTank(self, effective=True):
if self.__sustainableTank is None: if self.__sustainableTank is None:
if self.capStable: if self.capStable:
sustainable = {"armorRepair": self.extraAttributes["armorRepair"], sustainable = {
"shieldRepair": self.extraAttributes["shieldRepair"], "armorRepair" : self.extraAttributes["armorRepair"],
"hullRepair": self.extraAttributes["hullRepair"]} "shieldRepair": self.extraAttributes["shieldRepair"],
"hullRepair" : self.extraAttributes["hullRepair"]
}
else: else:
sustainable = {} sustainable = {}
repairers = [] repairers = []
# Map a repairer type to the attribute it uses # Map a repairer type to the attribute it uses
groupAttrMap = {"Armor Repair Unit": "armorDamageAmount", groupAttrMap = {
"Ancillary Armor Repairer": "armorDamageAmount", "Armor Repair Unit" : "armorDamageAmount",
"Hull Repair Unit": "structureDamageAmount", "Ancillary Armor Repairer": "armorDamageAmount",
"Shield Booster": "shieldBonus", "Hull Repair Unit" : "structureDamageAmount",
"Ancillary Shield Booster": "shieldBonus", "Shield Booster" : "shieldBonus",
"Remote Armor Repairer": "armorDamageAmount", "Ancillary Shield Booster": "shieldBonus",
"Remote Shield Booster": "shieldBonus"} "Remote Armor Repairer" : "armorDamageAmount",
"Remote Shield Booster" : "shieldBonus"
}
# Map repairer type to attribute # Map repairer type to attribute
groupStoreMap = {"Armor Repair Unit": "armorRepair", groupStoreMap = {
"Hull Repair Unit": "hullRepair", "Armor Repair Unit" : "armorRepair",
"Shield Booster": "shieldRepair", "Hull Repair Unit" : "hullRepair",
"Ancillary Shield Booster": "shieldRepair", "Shield Booster" : "shieldRepair",
"Remote Armor Repairer": "armorRepair", "Ancillary Shield Booster": "shieldRepair",
"Remote Shield Booster": "shieldRepair", "Remote Armor Repairer" : "armorRepair",
"Ancillary Armor Repairer": "armorRepair", } "Remote Shield Booster" : "shieldRepair",
"Ancillary Armor Repairer": "armorRepair",
}
capUsed = self.capUsed capUsed = self.capUsed
for attr in ("shieldRepair", "armorRepair", "hullRepair"): for attr in ("shieldRepair", "armorRepair", "hullRepair"):
@@ -1057,7 +1063,7 @@ class Fit(object):
# Sort repairers by efficiency. We want to use the most efficient repairers first # Sort repairers by efficiency. We want to use the most efficient repairers first
repairers.sort(key=lambda _mod: _mod.getModifiedItemAttr( repairers.sort(key=lambda _mod: _mod.getModifiedItemAttr(
groupAttrMap[_mod.item.group.name]) / _mod.getModifiedItemAttr("capacitorNeed"), reverse=True) groupAttrMap[_mod.item.group.name]) / _mod.getModifiedItemAttr("capacitorNeed"), reverse=True)
# Loop through every module until we're above peak recharge # Loop through every module until we're above peak recharge
# Most efficient first, as we sorted earlier. # Most efficient first, as we sorted earlier.
@@ -1370,10 +1376,10 @@ class Fit(object):
def __repr__(self): def __repr__(self):
return u"Fit(ID={}, ship={}, name={}) at {}".format( return u"Fit(ID={}, ship={}, name={}) at {}".format(
self.ID, self.ship.item.name, self.name, hex(id(self)) self.ID, self.ship.item.name, self.name, hex(id(self))
).encode('utf8') ).encode('utf8')
def __str__(self): def __str__(self):
return u"{} ({})".format( return u"{} ({})".format(
self.name, self.ship.item.name self.name, self.ship.item.name
).encode('utf8') ).encode('utf8')

View File

@@ -20,7 +20,6 @@
# noinspection PyPackageRequirements # noinspection PyPackageRequirements
import wx import wx
from gui.statsView import StatsView from gui.statsView import StatsView
from gui.bitmapLoader import BitmapLoader
from gui.utils.numberFormatter import formatAmount from gui.utils.numberFormatter import formatAmount