Raise errors on all insertions to handled lists which fail
This commit is contained in:
@@ -227,15 +227,15 @@ class HandledDroneCargoList(HandledList):
|
|||||||
|
|
||||||
def append(self, thing):
|
def append(self, thing):
|
||||||
HandledList.append(self, thing)
|
HandledList.append(self, thing)
|
||||||
|
|
||||||
if thing.isInvalid:
|
if thing.isInvalid:
|
||||||
self.remove(thing)
|
self.remove(thing)
|
||||||
|
raise HandledListActionError(thing)
|
||||||
|
|
||||||
def insert(self, idx, thing):
|
def insert(self, idx, thing):
|
||||||
HandledList.insert(self, idx, thing)
|
HandledList.insert(self, idx, thing)
|
||||||
|
|
||||||
if thing.isInvalid:
|
if thing.isInvalid:
|
||||||
self.remove(thing)
|
self.remove(thing)
|
||||||
|
raise(HandledListActionError)
|
||||||
|
|
||||||
|
|
||||||
class HandledImplantList(HandledList):
|
class HandledImplantList(HandledList):
|
||||||
@@ -244,7 +244,7 @@ class HandledImplantList(HandledList):
|
|||||||
if implant.isInvalid:
|
if implant.isInvalid:
|
||||||
HandledList.append(self, implant)
|
HandledList.append(self, implant)
|
||||||
self.remove(implant)
|
self.remove(implant)
|
||||||
return
|
raise HandledListActionError(implant)
|
||||||
|
|
||||||
self.makeRoom(implant)
|
self.makeRoom(implant)
|
||||||
HandledList.append(self, implant)
|
HandledList.append(self, implant)
|
||||||
@@ -269,7 +269,7 @@ class HandledBoosterList(HandledList):
|
|||||||
if booster.isInvalid:
|
if booster.isInvalid:
|
||||||
HandledList.append(self, booster)
|
HandledList.append(self, booster)
|
||||||
self.remove(booster)
|
self.remove(booster)
|
||||||
return
|
raise HandledListActionError(booster)
|
||||||
|
|
||||||
self.makeRoom(booster)
|
self.makeRoom(booster)
|
||||||
HandledList.append(self, booster)
|
HandledList.append(self, booster)
|
||||||
@@ -290,6 +290,7 @@ class HandledBoosterList(HandledList):
|
|||||||
|
|
||||||
|
|
||||||
class HandledSsoCharacterList(list):
|
class HandledSsoCharacterList(list):
|
||||||
|
|
||||||
def append(self, character):
|
def append(self, character):
|
||||||
old = next((x for x in self if x.client == character.client), None)
|
old = next((x for x in self if x.client == character.client), None)
|
||||||
if old is not None:
|
if old is not None:
|
||||||
@@ -301,18 +302,13 @@ class HandledSsoCharacterList(list):
|
|||||||
|
|
||||||
class HandledProjectedModList(HandledList):
|
class HandledProjectedModList(HandledList):
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
|
||||||
super().__init__(*args, **kwargs)
|
|
||||||
self.lastOpState = None
|
|
||||||
|
|
||||||
def append(self, proj):
|
def append(self, proj):
|
||||||
if proj.isInvalid:
|
if proj.isInvalid:
|
||||||
# we must include it before we remove it. doing it this way ensures
|
# we must include it before we remove it. doing it this way ensures
|
||||||
# rows and relationships in database are removed as well
|
# rows and relationships in database are removed as well
|
||||||
HandledList.append(self, proj)
|
HandledList.append(self, proj)
|
||||||
self.remove(proj)
|
self.remove(proj)
|
||||||
self.lastOpState = False
|
raise HandledListActionError(proj)
|
||||||
return
|
|
||||||
|
|
||||||
proj.projected = True
|
proj.projected = True
|
||||||
|
|
||||||
@@ -321,9 +317,7 @@ class HandledProjectedModList(HandledList):
|
|||||||
# Remove non-projectable modules
|
# Remove non-projectable modules
|
||||||
if not proj.item.isType("projected") and not proj.isExclusiveSystemEffect:
|
if not proj.item.isType("projected") and not proj.isExclusiveSystemEffect:
|
||||||
self.remove(proj)
|
self.remove(proj)
|
||||||
self.lastOpState = False
|
raise HandledListActionError(proj)
|
||||||
return
|
|
||||||
self.lastOpState = True
|
|
||||||
|
|
||||||
def insert(self, idx, proj):
|
def insert(self, idx, proj):
|
||||||
if proj.isInvalid:
|
if proj.isInvalid:
|
||||||
@@ -331,8 +325,7 @@ class HandledProjectedModList(HandledList):
|
|||||||
# rows and relationships in database are removed as well
|
# rows and relationships in database are removed as well
|
||||||
HandledList.insert(self, idx, proj)
|
HandledList.insert(self, idx, proj)
|
||||||
self.remove(proj)
|
self.remove(proj)
|
||||||
self.lastOpState = False
|
raise HandledListActionError(proj)
|
||||||
return
|
|
||||||
|
|
||||||
proj.projected = True
|
proj.projected = True
|
||||||
|
|
||||||
@@ -341,9 +334,7 @@ class HandledProjectedModList(HandledList):
|
|||||||
# Remove non-projectable modules
|
# Remove non-projectable modules
|
||||||
if not proj.item.isType("projected") and not proj.isExclusiveSystemEffect:
|
if not proj.item.isType("projected") and not proj.isExclusiveSystemEffect:
|
||||||
self.remove(proj)
|
self.remove(proj)
|
||||||
self.lastOpState = False
|
raise HandledListActionError(proj)
|
||||||
return
|
|
||||||
self.lastOpState = True
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def currentSystemEffect(self):
|
def currentSystemEffect(self):
|
||||||
@@ -374,7 +365,7 @@ class HandledProjectedDroneList(HandledDroneCargoList):
|
|||||||
# Remove invalid or non-projectable drones
|
# Remove invalid or non-projectable drones
|
||||||
if proj.isInvalid or not proj.item.isType("projected"):
|
if proj.isInvalid or not proj.item.isType("projected"):
|
||||||
self.remove(proj)
|
self.remove(proj)
|
||||||
return False
|
raise HandledListActionError(proj)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def insert(self, idx, proj):
|
def insert(self, idx, proj):
|
||||||
@@ -384,7 +375,7 @@ class HandledProjectedDroneList(HandledDroneCargoList):
|
|||||||
# Remove invalid or non-projectable drones
|
# Remove invalid or non-projectable drones
|
||||||
if proj.isInvalid or not proj.item.isType("projected"):
|
if proj.isInvalid or not proj.item.isType("projected"):
|
||||||
self.remove(proj)
|
self.remove(proj)
|
||||||
return False
|
raise HandledListActionError(proj)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user