blob: 0ae21ea97a063cd0420535e46ac8430e96777b52 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
from operationscore.Behavior import *
import pdb
class RecursiveDecay(Behavior):
"""RecursiveDecay is an event to allow recursive hooks to stop recursing after a certain number
of iterations specified in
<InitialResponseCount> -- Int, number of total responses.
Designed to be used as part of a recursive hook.
"""
def processResponse(self, sensorInputs, recursiveInputs):
ret = []
for response in sensorInputs:
if not 'ResponsesLeft' in response:
response['ResponsesLeft'] = self['InitialResponseCount']
else:
response['ResponsesLeft'] -= 1
if response['ResponsesLeft'] > 0:
ret.append(response)
return (ret, []) #no direct ouput
|