Merge branch 'master' into singularity
This commit is contained in:
@@ -17,9 +17,8 @@
|
||||
# along with eos. If not, see <http://www.gnu.org/licenses/>.
|
||||
# ===============================================================================
|
||||
|
||||
from logbook import Logger
|
||||
|
||||
from eos.exception import HandledListActionError
|
||||
from logbook import Logger
|
||||
|
||||
|
||||
pyfalog = Logger(__name__)
|
||||
@@ -122,7 +121,7 @@ class HandledList(list):
|
||||
|
||||
class HandledModuleList(HandledList):
|
||||
|
||||
def append(self, mod, raiseFailure=False):
|
||||
def append(self, mod):
|
||||
emptyPosition = float("Inf")
|
||||
for i in range(len(self)):
|
||||
currMod = self[i]
|
||||
@@ -136,41 +135,25 @@ class HandledModuleList(HandledList):
|
||||
self.__toModule(emptyPosition, mod)
|
||||
if mod.isInvalid:
|
||||
self.__toDummy(mod.position)
|
||||
if raiseFailure:
|
||||
raise HandledListActionError(mod)
|
||||
else:
|
||||
return
|
||||
return
|
||||
else:
|
||||
self.appendIgnoreEmpty(mod)
|
||||
|
||||
self.appendIgnoreEmpty(mod, raiseFailure=raiseFailure)
|
||||
|
||||
def appendIgnoreEmpty(self, mod, raiseFailure=False):
|
||||
def appendIgnoreEmpty(self, mod):
|
||||
mod.position = len(self)
|
||||
HandledList.append(self, mod)
|
||||
if mod.isInvalid:
|
||||
self.remove(mod)
|
||||
if raiseFailure:
|
||||
raise HandledListActionError(mod)
|
||||
else:
|
||||
return
|
||||
|
||||
def replace(self, idx, mod, raiseFailure=False):
|
||||
def replace(self, idx, mod):
|
||||
try:
|
||||
oldMod = self[idx]
|
||||
except IndexError:
|
||||
if raiseFailure:
|
||||
raise HandledListActionError(mod)
|
||||
else:
|
||||
return
|
||||
return
|
||||
self.__toModule(idx, mod)
|
||||
if mod.isInvalid:
|
||||
self.__toModule(idx, oldMod)
|
||||
if raiseFailure:
|
||||
raise HandledListActionError(mod)
|
||||
else:
|
||||
return
|
||||
|
||||
def replaceRackPosition(self, rackPosition, mod, raiseFailure=False):
|
||||
def replaceRackPosition(self, rackPosition, mod):
|
||||
listPositions = []
|
||||
for currPos in range(len(self)):
|
||||
currMod = self[currPos]
|
||||
@@ -180,7 +163,7 @@ class HandledModuleList(HandledList):
|
||||
try:
|
||||
modListPosition = listPositions[rackPosition]
|
||||
except IndexError:
|
||||
self.appendIgnoreEmpty(mod, raiseFailure=raiseFailure)
|
||||
self.appendIgnoreEmpty(mod)
|
||||
else:
|
||||
oldMod = self[modListPosition]
|
||||
if mod.isEmpty:
|
||||
@@ -193,12 +176,8 @@ class HandledModuleList(HandledList):
|
||||
self.__toDummy(modListPosition)
|
||||
else:
|
||||
self.__toModule(modListPosition, oldMod)
|
||||
if raiseFailure:
|
||||
raise HandledListActionError(mod)
|
||||
else:
|
||||
return
|
||||
|
||||
def insert(self, idx, mod, raiseFailure=False):
|
||||
def insert(self, idx, mod):
|
||||
mod.position = idx
|
||||
i = idx
|
||||
while i < len(self):
|
||||
@@ -207,10 +186,6 @@ class HandledModuleList(HandledList):
|
||||
HandledList.insert(self, idx, mod)
|
||||
if mod.isInvalid:
|
||||
self.remove(mod)
|
||||
if raiseFailure:
|
||||
raise HandledListActionError(mod)
|
||||
else:
|
||||
return
|
||||
|
||||
def remove(self, mod):
|
||||
HandledList.remove(self, mod)
|
||||
@@ -248,59 +223,39 @@ class HandledDroneCargoList(HandledList):
|
||||
for o in self.find(item):
|
||||
return o
|
||||
|
||||
def append(self, thing, raiseFailure=False):
|
||||
def append(self, thing):
|
||||
HandledList.append(self, thing)
|
||||
if thing.isInvalid:
|
||||
self.remove(thing)
|
||||
if raiseFailure:
|
||||
raise HandledListActionError(thing)
|
||||
else:
|
||||
return
|
||||
|
||||
def insert(self, idx, thing, raiseFailure=False):
|
||||
def insert(self, idx, thing):
|
||||
HandledList.insert(self, idx, thing)
|
||||
if thing.isInvalid:
|
||||
self.remove(thing)
|
||||
if raiseFailure:
|
||||
raise HandledListActionError(thing)
|
||||
else:
|
||||
return
|
||||
|
||||
|
||||
class HandledImplantList(HandledList):
|
||||
|
||||
def append(self, implant, raiseFailure=False):
|
||||
def append(self, implant):
|
||||
if implant.isInvalid:
|
||||
HandledList.append(self, implant)
|
||||
self.remove(implant)
|
||||
if raiseFailure:
|
||||
raise HandledListActionError(implant)
|
||||
else:
|
||||
return
|
||||
return
|
||||
if self.__slotCheck(implant):
|
||||
HandledList.append(self, implant)
|
||||
self.remove(implant)
|
||||
if raiseFailure:
|
||||
raise HandledListActionError(implant)
|
||||
else:
|
||||
return
|
||||
return
|
||||
HandledList.append(self, implant)
|
||||
|
||||
def insert(self, idx, implant, raiseFailure=False):
|
||||
def insert(self, idx, implant):
|
||||
if implant.isInvalid:
|
||||
HandledList.insert(self, idx, implant)
|
||||
self.remove(implant)
|
||||
if raiseFailure:
|
||||
raise HandledListActionError(implant)
|
||||
else:
|
||||
return
|
||||
return
|
||||
if self.__slotCheck(implant):
|
||||
HandledList.insert(self, idx, implant)
|
||||
self.remove(implant)
|
||||
if raiseFailure:
|
||||
raise HandledListActionError(implant)
|
||||
else:
|
||||
return
|
||||
return
|
||||
HandledList.insert(self, idx, implant)
|
||||
|
||||
def makeRoom(self, implant):
|
||||
@@ -322,38 +277,26 @@ class HandledImplantList(HandledList):
|
||||
|
||||
class HandledBoosterList(HandledList):
|
||||
|
||||
def append(self, booster, raiseFailure=False):
|
||||
def append(self, booster):
|
||||
if booster.isInvalid:
|
||||
HandledList.append(self, booster)
|
||||
self.remove(booster)
|
||||
if raiseFailure:
|
||||
raise HandledListActionError(booster)
|
||||
else:
|
||||
return
|
||||
return
|
||||
if self.__slotCheck(booster):
|
||||
HandledList.append(self, booster)
|
||||
self.remove(booster)
|
||||
if raiseFailure:
|
||||
raise HandledListActionError(booster)
|
||||
else:
|
||||
return
|
||||
return
|
||||
HandledList.append(self, booster)
|
||||
|
||||
def insert(self, idx, booster, raiseFailure=False):
|
||||
def insert(self, idx, booster):
|
||||
if booster.isInvalid:
|
||||
HandledList.insert(self, idx, booster)
|
||||
self.remove(booster)
|
||||
if raiseFailure:
|
||||
raise HandledListActionError(booster)
|
||||
else:
|
||||
return
|
||||
return
|
||||
if self.__slotCheck(booster):
|
||||
HandledList.insert(self, idx, booster)
|
||||
self.remove(booster)
|
||||
if raiseFailure:
|
||||
raise HandledListActionError(booster)
|
||||
else:
|
||||
return
|
||||
return
|
||||
HandledList.insert(self, idx, booster)
|
||||
|
||||
def makeRoom(self, booster):
|
||||
@@ -386,51 +329,31 @@ class HandledSsoCharacterList(list):
|
||||
|
||||
class HandledProjectedModList(HandledList):
|
||||
|
||||
def append(self, proj, raiseFailure=False):
|
||||
def append(self, proj):
|
||||
if proj.isInvalid:
|
||||
# we must include it before we remove it. doing it this way ensures
|
||||
# rows and relationships in database are removed as well
|
||||
HandledList.append(self, proj)
|
||||
self.remove(proj)
|
||||
if raiseFailure:
|
||||
raise HandledListActionError(proj)
|
||||
else:
|
||||
return
|
||||
|
||||
return
|
||||
proj.projected = True
|
||||
|
||||
HandledList.append(self, proj)
|
||||
|
||||
# Remove non-projectable modules
|
||||
if not proj.item.isType("projected") and not proj.isExclusiveSystemEffect:
|
||||
self.remove(proj)
|
||||
if raiseFailure:
|
||||
raise HandledListActionError(proj)
|
||||
else:
|
||||
return
|
||||
|
||||
def insert(self, idx, proj, raiseFailure=False):
|
||||
def insert(self, idx, proj):
|
||||
if proj.isInvalid:
|
||||
# we must include it before we remove it. doing it this way ensures
|
||||
# rows and relationships in database are removed as well
|
||||
HandledList.insert(self, idx, proj)
|
||||
self.remove(proj)
|
||||
if raiseFailure:
|
||||
raise HandledListActionError(proj)
|
||||
else:
|
||||
return
|
||||
|
||||
return
|
||||
proj.projected = True
|
||||
|
||||
HandledList.insert(self, idx, proj)
|
||||
|
||||
# Remove non-projectable modules
|
||||
if not proj.item.isType("projected") and not proj.isExclusiveSystemEffect:
|
||||
self.remove(proj)
|
||||
if raiseFailure:
|
||||
raise HandledListActionError(proj)
|
||||
else:
|
||||
return
|
||||
|
||||
@property
|
||||
def currentSystemEffect(self):
|
||||
@@ -454,31 +377,21 @@ class HandledProjectedModList(HandledList):
|
||||
|
||||
class HandledProjectedDroneList(HandledDroneCargoList):
|
||||
|
||||
def append(self, proj, raiseFailure=False):
|
||||
def append(self, proj):
|
||||
proj.projected = True
|
||||
HandledList.append(self, proj)
|
||||
|
||||
# Remove invalid or non-projectable drones
|
||||
if proj.isInvalid or not proj.item.isType("projected"):
|
||||
self.remove(proj)
|
||||
proj.projected = False
|
||||
if raiseFailure:
|
||||
raise HandledListActionError(proj)
|
||||
else:
|
||||
return
|
||||
|
||||
def insert(self, idx, proj, raiseFailure=False):
|
||||
def insert(self, idx, proj):
|
||||
proj.projected = True
|
||||
HandledList.insert(self, idx, proj)
|
||||
|
||||
# Remove invalid or non-projectable drones
|
||||
if proj.isInvalid or not proj.item.isType("projected"):
|
||||
self.remove(proj)
|
||||
proj.projected = False
|
||||
if raiseFailure:
|
||||
raise HandledListActionError(proj)
|
||||
else:
|
||||
return
|
||||
|
||||
|
||||
class HandledItem(object):
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
class HandledListActionError(Exception):
|
||||
...
|
||||
@@ -2,7 +2,6 @@ import wx
|
||||
from logbook import Logger
|
||||
|
||||
import eos.db
|
||||
from eos.exception import HandledListActionError
|
||||
from service.fit import Fit
|
||||
|
||||
|
||||
@@ -35,9 +34,8 @@ class CalcAddBoosterCommand(wx.Command):
|
||||
self.oldPosition, self.oldBoosterInfo = fit.boosters.makeRoom(newBooster)
|
||||
|
||||
if self.newPosition is not None:
|
||||
try:
|
||||
fit.boosters.insert(self.newPosition, newBooster, raiseFailure=True)
|
||||
except HandledListActionError:
|
||||
fit.boosters.insert(self.newPosition, newBooster)
|
||||
if newBooster not in fit.boosters:
|
||||
pyfalog.warning('Failed to insert to list')
|
||||
cmd = CalcAddBoosterCommand(
|
||||
fitID=self.fitID,
|
||||
@@ -47,9 +45,8 @@ class CalcAddBoosterCommand(wx.Command):
|
||||
cmd.Do()
|
||||
return False
|
||||
else:
|
||||
try:
|
||||
fit.boosters.append(newBooster, raiseFailure=True)
|
||||
except HandledListActionError:
|
||||
fit.boosters.append(newBooster)
|
||||
if newBooster not in fit.boosters:
|
||||
pyfalog.warning('Failed to append to list')
|
||||
cmd = CalcAddBoosterCommand(
|
||||
fitID=self.fitID,
|
||||
|
||||
@@ -2,7 +2,6 @@ import wx
|
||||
from logbook import Logger
|
||||
|
||||
import eos.db
|
||||
from eos.exception import HandledListActionError
|
||||
from service.fit import Fit
|
||||
|
||||
|
||||
@@ -25,9 +24,8 @@ class CalcAddCargoCommand(wx.Command):
|
||||
cargo.amount += self.cargoInfo.amount
|
||||
else:
|
||||
cargo = self.cargoInfo.toCargo()
|
||||
try:
|
||||
fit.cargo.append(cargo, raiseFailure=True)
|
||||
except HandledListActionError:
|
||||
fit.cargo.append(cargo)
|
||||
if cargo not in fit.cargo:
|
||||
pyfalog.warning('Failed to append to list')
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
|
||||
@@ -3,7 +3,6 @@ import wx
|
||||
from logbook import Logger
|
||||
|
||||
import eos.db
|
||||
from eos.exception import HandledListActionError
|
||||
from gui.fitCommands.helpers import DroneInfo, droneStackLimit
|
||||
from service.fit import Fit
|
||||
from service.market import Market
|
||||
@@ -50,9 +49,8 @@ class CalcAddLocalDroneCommand(wx.Command):
|
||||
if not self.ignoreRestrictions and not drone.fits(fit):
|
||||
pyfalog.warning('Drone does not fit')
|
||||
return False
|
||||
try:
|
||||
fit.drones.append(drone, raiseFailure=True)
|
||||
except HandledListActionError:
|
||||
fit.drones.append(drone)
|
||||
if drone not in fit.drones:
|
||||
pyfalog.warning('Failed to append to list')
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
|
||||
@@ -2,7 +2,6 @@ import wx
|
||||
from logbook import Logger
|
||||
|
||||
import eos.db
|
||||
from eos.exception import HandledListActionError
|
||||
from gui.fitCommands.helpers import DroneInfo
|
||||
from service.fit import Fit
|
||||
|
||||
@@ -48,9 +47,8 @@ class CalcRemoveLocalDroneCommand(wx.Command):
|
||||
drone = self.savedDroneInfo.toDrone()
|
||||
if drone is None:
|
||||
return False
|
||||
try:
|
||||
fit.drones.insert(self.position, drone, raiseFailure=True)
|
||||
except HandledListActionError:
|
||||
fit.drones.insert(self.position, drone)
|
||||
if drone not in fit.drones:
|
||||
pyfalog.warning('Failed to insert to list')
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
|
||||
@@ -4,7 +4,6 @@ import wx
|
||||
from logbook import Logger
|
||||
|
||||
import eos.db
|
||||
from eos.exception import HandledListActionError
|
||||
from gui.fitCommands.helpers import DroneInfo
|
||||
from service.fit import Fit
|
||||
|
||||
@@ -43,9 +42,8 @@ class CalcAddProjectedDroneCommand(wx.Command):
|
||||
if not drone.item.isType('projected'):
|
||||
pyfalog.debug('Drone is not projectable')
|
||||
return False
|
||||
try:
|
||||
fit.projectedDrones.append(drone, raiseFailure=True)
|
||||
except HandledListActionError:
|
||||
fit.projectedDrones.append(drone)
|
||||
if drone not in fit.projectedDrones:
|
||||
pyfalog.warning('Failed to append to list')
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
|
||||
@@ -2,7 +2,6 @@ import wx
|
||||
from logbook import Logger
|
||||
|
||||
import eos.db
|
||||
from eos.exception import HandledListActionError
|
||||
from service.fit import Fit
|
||||
|
||||
|
||||
@@ -41,18 +40,16 @@ class CalcAddLocalFighterCommand(wx.Command):
|
||||
fighter.active = True
|
||||
|
||||
if self.position is None:
|
||||
try:
|
||||
fit.fighters.append(fighter, raiseFailure=True)
|
||||
except HandledListActionError:
|
||||
fit.fighters.append(fighter)
|
||||
if fighter not in fit.fighters:
|
||||
pyfalog.warning('Failed to append to list')
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
return False
|
||||
self.position = fit.fighters.index(fighter)
|
||||
else:
|
||||
try:
|
||||
fit.fighters.insert(self.position, fighter, raiseFailure=True)
|
||||
except HandledListActionError:
|
||||
fit.fighters.insert(self.position, fighter)
|
||||
if fighter not in fit.fighters:
|
||||
pyfalog.warning('Failed to insert to list')
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
|
||||
@@ -2,7 +2,6 @@ import wx
|
||||
from logbook import Logger
|
||||
|
||||
import eos.db
|
||||
from eos.exception import HandledListActionError
|
||||
from service.fit import Fit
|
||||
|
||||
|
||||
@@ -25,16 +24,14 @@ class CalcAddProjectedFighterCommand(wx.Command):
|
||||
return False
|
||||
fit = Fit.getInstance().getFit(self.fitID)
|
||||
if self.position is not None:
|
||||
try:
|
||||
fit.projectedFighters.insert(self.position, fighter, raiseFailure=True)
|
||||
except HandledListActionError:
|
||||
fit.projectedFighters.insert(self.position, fighter)
|
||||
if fighter not in fit.projectedFighters:
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
return False
|
||||
else:
|
||||
try:
|
||||
fit.projectedFighters.append(fighter, raiseFailure=True)
|
||||
except HandledListActionError:
|
||||
fit.projectedFighters.append(fighter)
|
||||
if fighter not in fit.projectedFighters:
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
return False
|
||||
|
||||
@@ -2,7 +2,6 @@ import wx
|
||||
from logbook import Logger
|
||||
|
||||
import eos.db
|
||||
from eos.exception import HandledListActionError
|
||||
from service.fit import Fit
|
||||
|
||||
|
||||
@@ -35,9 +34,8 @@ class CalcAddImplantCommand(wx.Command):
|
||||
self.oldPosition, self.oldImplantInfo = fit.implants.makeRoom(newImplant)
|
||||
|
||||
if self.newPosition is not None:
|
||||
try:
|
||||
fit.implants.insert(self.newPosition, newImplant, raiseFailure=True)
|
||||
except HandledListActionError:
|
||||
fit.implants.insert(self.newPosition, newImplant)
|
||||
if newImplant not in fit.implants:
|
||||
pyfalog.warning('Failed to insert to list')
|
||||
cmd = CalcAddImplantCommand(
|
||||
fitID=self.fitID,
|
||||
@@ -47,9 +45,8 @@ class CalcAddImplantCommand(wx.Command):
|
||||
cmd.Do()
|
||||
return False
|
||||
else:
|
||||
try:
|
||||
fit.implants.append(newImplant, raiseFailure=True)
|
||||
except HandledListActionError:
|
||||
fit.implants.append(newImplant)
|
||||
if newImplant not in fit.implants:
|
||||
pyfalog.warning('Failed to append to list')
|
||||
cmd = CalcAddImplantCommand(
|
||||
fitID=self.fitID,
|
||||
|
||||
@@ -2,7 +2,6 @@ import wx
|
||||
from logbook import Logger
|
||||
|
||||
import eos.db
|
||||
from eos.exception import HandledListActionError
|
||||
from gui.fitCommands.helpers import restoreCheckedStates, stateLimit
|
||||
from service.fit import Fit
|
||||
|
||||
@@ -55,9 +54,8 @@ class CalcAddLocalModuleCommand(wx.Command):
|
||||
if not newMod.fits(fit):
|
||||
pyfalog.warning('Module does not fit')
|
||||
return False
|
||||
try:
|
||||
fit.modules.append(newMod, raiseFailure=True)
|
||||
except HandledListActionError:
|
||||
fit.modules.append(newMod)
|
||||
if newMod not in fit.modules:
|
||||
pyfalog.warning('Failed to append to list')
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
|
||||
@@ -4,7 +4,6 @@ import wx
|
||||
from logbook import Logger
|
||||
|
||||
import eos.db
|
||||
from eos.exception import HandledListActionError
|
||||
from gui.fitCommands.helpers import restoreCheckedStates
|
||||
from service.fit import Fit
|
||||
|
||||
@@ -31,9 +30,8 @@ class CalcCloneLocalModuleCommand(wx.Command):
|
||||
return False
|
||||
if not fit.modules[self.dstPosition].isEmpty:
|
||||
return False
|
||||
try:
|
||||
fit.modules.replace(self.dstPosition, copyMod, raiseFailure=True)
|
||||
except HandledListActionError:
|
||||
fit.modules.replace(self.dstPosition, copyMod)
|
||||
if copyMod not in fit.modules:
|
||||
pyfalog.warning('Failed to replace module')
|
||||
eos.db.commit()
|
||||
return False
|
||||
|
||||
@@ -2,7 +2,6 @@ import wx
|
||||
from logbook import Logger
|
||||
|
||||
import eos.db
|
||||
from eos.exception import HandledListActionError
|
||||
from gui.fitCommands.helpers import ModuleInfo, restoreCheckedStates, stateLimit
|
||||
from service.fit import Fit
|
||||
|
||||
@@ -53,9 +52,8 @@ class CalcReplaceLocalModuleCommand(wx.Command):
|
||||
pyfalog.warning('Invalid charge')
|
||||
self.Undo()
|
||||
return False
|
||||
try:
|
||||
fit.modules.replace(self.position, newMod, raiseFailure=True)
|
||||
except HandledListActionError:
|
||||
fit.modules.replace(self.position, newMod)
|
||||
if newMod not in fit.modules:
|
||||
pyfalog.warning('Failed to replace in list')
|
||||
self.Undo()
|
||||
return False
|
||||
@@ -87,9 +85,8 @@ class CalcReplaceLocalModuleCommand(wx.Command):
|
||||
if oldMod is None:
|
||||
return False
|
||||
fit.modules.free(self.position)
|
||||
try:
|
||||
fit.modules.replace(self.position, oldMod, raiseFailure=True)
|
||||
except HandledListActionError:
|
||||
fit.modules.replace(self.position, oldMod)
|
||||
if oldMod not in fit.modules:
|
||||
pyfalog.warning('Failed to replace in list')
|
||||
self.Do()
|
||||
return False
|
||||
|
||||
@@ -2,7 +2,6 @@ import wx
|
||||
from logbook import Logger
|
||||
|
||||
import eos.db
|
||||
from eos.exception import HandledListActionError
|
||||
from service.fit import Fit
|
||||
|
||||
|
||||
@@ -33,16 +32,14 @@ class CalcSwapLocalModuleCommand(wx.Command):
|
||||
mod2 = fit.modules[position2]
|
||||
fit.modules.free(position1)
|
||||
fit.modules.free(position2)
|
||||
try:
|
||||
fit.modules.replace(position2, mod1, raiseFailure=True)
|
||||
except HandledListActionError:
|
||||
fit.modules.replace(position2, mod1)
|
||||
if len(fit.modules) <= position2 or fit.modules[position2] is not mod1:
|
||||
fit.modules.replace(position1, mod1)
|
||||
fit.modules.replace(position2, mod2)
|
||||
eos.db.commit()
|
||||
return False
|
||||
try:
|
||||
fit.modules.replace(position1, mod2, raiseFailure=True)
|
||||
except HandledListActionError:
|
||||
fit.modules.replace(position1, mod2)
|
||||
if len(fit.modules) <= position1 or fit.modules[position1] is not mod2:
|
||||
fit.modules.free(position2)
|
||||
fit.modules.replace(position1, mod1)
|
||||
fit.modules.replace(position2, mod2)
|
||||
|
||||
@@ -3,7 +3,6 @@ from logbook import Logger
|
||||
|
||||
import eos.db
|
||||
from eos.const import FittingModuleState
|
||||
from eos.exception import HandledListActionError
|
||||
from gui.fitCommands.helpers import restoreCheckedStates
|
||||
from service.fit import Fit
|
||||
|
||||
@@ -39,16 +38,14 @@ class CalcAddProjectedModuleCommand(wx.Command):
|
||||
self.oldPosition, self.oldModInfo = fit.projectedModules.makeRoom(newMod)
|
||||
|
||||
if self.newPosition is not None:
|
||||
try:
|
||||
fit.projectedModules.insert(self.newPosition, newMod, raiseFailure=True)
|
||||
except HandledListActionError:
|
||||
fit.projectedModules.insert(self.newPosition, newMod)
|
||||
if newMod not in fit.projectedModules:
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
return False
|
||||
else:
|
||||
try:
|
||||
fit.projectedModules.append(newMod, raiseFailure=True)
|
||||
except HandledListActionError:
|
||||
fit.projectedModules.append(newMod)
|
||||
if newMod not in fit.projectedModules:
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
return False
|
||||
|
||||
Reference in New Issue
Block a user