# Path: bl/utils.py
# def getClock(clock=None):
#     if clock is None:
#         from bl.scheduler import BeatClock
#         return BeatClock.defaultClock
#     return clock
# 
# def exhaustCall(v):
#     """
#     Get an uncallable value at the end of a call chain or `v` itself
#     if `v` is not callable.
#     """
#     while callable(v):
#         v = v()
#     return v


from itertools import cycle
from twisted.python import log
from twisted.python.failure import Failure
from bl.utils import getClock, exhaustCall




__all__ = ['SchedulePlayer', 'schedule', 'childSchedule', 'metronome',
           'OneSchedulePlayerMixin', 'timing']


class SchedulePlayer(object):
    """
    A schedule player plays a "schedule" where a schedule is a generator (has
    next()) that yields 3-tuples of the form:

        (relative_ticks:int, func:function, args:dict)

    C{relative_ticks} is the number of ticks after "resuming" the scheduler
    from its last ticks value (attribue C{last}) (which begins at 0 unless
    customized).  The function C{func} will be scheduled to be called with args
    as keyword arguments, thus your callables should have well-defined
    signature (even after any decoration).
    """

    def __init__(self, schedule, clock=None):
        self.schedule = schedule

# Path: bl/utils.py
# def getClock(clock=None):
#     if clock is None:
#         from bl.scheduler import BeatClock
#         return BeatClock.defaultClock
#     return clock
# 
# def exhaustCall(v):
#     """
#     Get an uncallable value at the end of a call chain or `v` itself
#     if `v` is not callable.
#     """
#     while callable(v):
#         v = v()
#     return v


# Path: bl/orchestra/base.py
from itertools import cycle
from twisted.python import log
from twisted.python.failure import Failure
from bl.utils import getClock, exhaustCall





__all__ = ['SchedulePlayer', 'schedule', 'childSchedule', 'metronome',
           'OneSchedulePlayerMixin', 'timing']


class SchedulePlayer(object):
    """
    A schedule player plays a "schedule" where a schedule is a generator (has
    next()) that yields 3-tuples of the form:

        (relative_ticks:int, func:function, args:dict)

    C{relative_ticks} is the number of ticks after "resuming" the scheduler
    from its last ticks value (attribue C{last}) (which begins at 0 unless
    customized).  The function C{func} will be scheduled to be called with args
    as keyword arguments, thus your callables should have well-defined
    signature (even after any decoration).
    """

    def __init__(self, schedule, clock=None):
        self.schedule = schedule

        self.clock = getClock(clock)