in gateway/gateway.py [0:0]
def remove_expired_refs(actions: ActionsYAML):
"""
Remove expired references from the actions dictionary.
Args:
actions: Dictionary of actions and their references
"""
refs_to_remove: list[tuple[str, str]] = []
for name, action in actions.items():
refs_to_remove.extend(
(name, ref)
for ref, details in action.items()
if details["expires_at"] <= date.today() and not details.get("keep")
)
# Changing the iterable during iteration raises a RuntimeError
for name, ref in refs_to_remove:
del actions[name][ref]
# remove Actions without refs
if not actions[name]:
del actions[name]