def previous(self):
self.jump(self._index - 1)
- def filter(self, keeper_fn=lambda item:True):
+ def filter(self, keeper_fn=lambda item:True, *args, **kwargs):
c = copy.deepcopy(self)
for item in reversed(c):
- if keeper_fn(item) != True:
+ if keeper_fn(item, *args, **kwargs) != True:
c.remove(item)
try: # attempt to maintain the same current item
c._index = c.index(self.current())
self.arguments.append(
Argument(name='filter', type='function', optional=False,
help="""
-Function returning `True` for "good" curves. `filter(curve) -> True/False`.
+Function returning `True` for "good" curves.
+`filter(curve, hooke, inqueue, outqueue, params) -> True/False`.
""".strip()))
def _run(self, hooke, inqueue, outqueue, params):
filter_fn = params['filter']
else:
filter_fn = self.filter_fn
- p = params['playlist'].filter(filter_fn)
+ p = params['playlist'].filter(filter_fn,
+ hooke=hooke, inqueue=inqueue, outqueue=outqueue, params=params)
hooke.playlists.add(p)
outqueue.put(p)
def __init__(self, plugin):
super(NoteFilterCommand, self).__init__(
plugin, name='note filter playlist',
- filter_fn=lambda curve : \
+ filter_fn=lambda curve, hooke, inqueue, outqueue, params : \
'note' in curve.info and curve.info['note'] != None)