def items(self, reverse=False):
"""Iterate through `self` calling `_setup_item` on each item
before yielding.
+
+ Notes
+ -----
+ Updates :attr:`_index` during the iteration so
+ :func:`~hooke.plugin.curve.current_curve_callback` works as
+ expected in :class:`~hooke.command.Command`\s called from
+ :class:`~hooke.plugin.playlist.ApplyCommandStack`. After the
+ iteration completes, :attr:`_index` is restored to its
+ original value.
"""
+ index = self._index
items = self
if reverse == True:
- items = reversed(self)
- for item in items:
+ items = reversed(enumerate(self))
+ else:
+ items = enumerate(self)
+ for i,item in items:
+ self._index = i
self._setup_item(item)
yield item
+ self._index = index
def filter(self, keeper_fn=lambda item:True, *args, **kwargs):
c = copy.deepcopy(self)