1
# Copyright 2010 Canonical Ltd. This software is licensed under the
2
# GNU Affero General Public License version 3 (see the file LICENSE).
4
"""Time an action which calls other timed actions."""
7
__all__ = ['NestingTimedAction']
14
from timedaction import TimedAction
17
class NestingTimedAction(TimedAction):
18
"""A variation of TimedAction which creates a nested environment.
20
This is done by recording two 0 length timed actions in the timeline:
21
one at the start of the action and one at the end, with -start and
22
-stop appended to their categories.
24
See `TimedAction` for more information.
28
self.duration = datetime.timedelta()
29
self._category = self.category
30
self.category = self._category + '-start'
33
"""Mark the TimedAction as finished."""
34
end = self.timeline.start(self._category + '-stop', self.detail)
35
end.duration = datetime.timedelta()