forked from mirror/Archipelago
MultiServer: Safe DataStorage .pop (#5060)
* Make datastorage .pop not throw on missing key or index * Reworked to use logic rather than exception catching
This commit is contained in:
@@ -69,6 +69,12 @@ def remove_from_list(container, value):
|
||||
|
||||
|
||||
def pop_from_container(container, value):
|
||||
if isinstance(container, list) and isinstance(value, int) and len(container) <= value:
|
||||
return container
|
||||
|
||||
if isinstance(container, dict) and value not in container:
|
||||
return container
|
||||
|
||||
try:
|
||||
container.pop(value)
|
||||
except ValueError:
|
||||
|
||||
Reference in New Issue
Block a user