(self, states=None, trigger='next_state',
                                loop=True, loop_includes_initial=True,
                                conditions=None, unless=None, before=None,
                                after=None, prepare=None, **kwargs)
Add a set of transitions that move linearly from state to state.
        Args:
            states (list): A list of state names defining the order of the
                transitions. E.g., ['A', 'B', 'C'] will generate transitions
                for A --> B, B --> C, and C --> A (if loop is True). If states
                is None, all states in the current instance will be used.
            trigger (str): The name of the trigger method that advances to
                the next state in the sequence.
            loop (boolean): Whether or not to add a transition from the last
                state to the first state.
            loop_includes_initial (boolean): If no initial state was defined in
                the machine, setting this to True will cause the _initial state
                placeholder to be included in the added transitions. This argument
                has no effect if the states argument is passed without the
                initial state included.
            conditions (str or list): Condition(s) that must pass in order
                for the transition to take place. Either a list providing the
                name of a callable, or a list of callables. For the transition
                to occur, ALL callables must return True.
            unless (str or list): Condition(s) that must return False in order
                for the transition to occur. Behaves just like conditions arg
                otherwise.
            before (str or list): Callables to call before the transition.
            after (str or list): Callables to call after the transition.
            prepare (str or list): Callables to call when the trigger is activated
            **kwargs: Additional arguments which can be passed to the created transition.
                This is useful if you plan to extend Machine.Transition and require more parameters.
Add a set of transitions that move linearly from state to state.
        Args:
            states (list): A list of state names defining the order of the
                transitions. E.g., ['A', 'B', 'C'] will generate transitions
                for A --> B, B --> C, and C --> A (if loop is True). If states
                is None, all states in the current instance will be used.
            trigger (str): The name of the trigger method that advances to
                the next state in the sequence.
            loop (boolean): Whether or not to add a transition from the last
                state to the first state.
            loop_includes_initial (boolean): If no initial state was defined in
                the machine, setting this to True will cause the _initial state
                placeholder to be included in the added transitions. This argument
                has no effect if the states argument is passed without the
                initial state included.
            conditions (str or list): Condition(s) that must pass in order
                for the transition to take place. Either a list providing the
                name of a callable, or a list of callables. For the transition
                to occur, ALL callables must return True.
            unless (str or list): Condition(s) that must return False in order
                for the transition to occur. Behaves just like conditions arg
                otherwise.
            before (str or list): Callables to call before the transition.
            after (str or list): Callables to call after the transition.
            prepare (str or list): Callables to call when the trigger is activated
            **kwargs: Additional arguments which can be passed to the created transition.
                This is useful if you plan to extend Machine.Transition and require more parameters.
Add a set of transitions that move linearly from state to state . Args : states ( list ) : A list of state names defining the order of the transitions . E . g . [ A B C ] will generate transitions for A -- > B B -- > C and C -- > A ( if loop is True ) . If states is None all states in the current instance will be used . trigger ( str ) : The name of the trigger method that advances to the next state in the sequence . loop ( boolean ) : Whether or not to add a transition from the last state to the first state . loop_includes_initial ( boolean ) : If no initial state was defined in the machine setting this to True will cause the _initial state placeholder to be included in the added transitions . This argument has no effect if the states argument is passed without the initial state included . conditions ( str or list ) : Condition ( s ) that must pass in order for the transition to take place . Either a list providing the name of a callable or a list of callables . For the transition to occur ALL callables must return True . unless ( str or list ) : Condition ( s ) that must return False in order for the transition to occur . Behaves just like conditions arg otherwise . before ( str or list ) : Callables to call before the transition . after ( str or list ) : Callables to call after the transition . prepare ( str or list ) : Callables to call when the trigger is activated ** kwargs : Additional arguments which can be passed to the created transition . This is useful if you plan to extend Machine . Transition and require more parameters .
def add_ordered_transitions(self, states=None, trigger='next_state',
                                loop=True, loop_includes_initial=True,
                                conditions=None, unless=None, before=None,
                                after=None, prepare=None, **kwargs):
        """ Add a set of transitions that move linearly from state to state.
        Args:
            states (list): A list of state names defining the order of the
                transitions. E.g., ['A', 'B', 'C'] will generate transitions
                for A --> B, B --> C, and C --> A (if loop is True). If states
                is None, all states in the current instance will be used.
            trigger (str): The name of the trigger method that advances to
                the next state in the sequence.
            loop (boolean): Whether or not to add a transition from the last
                state to the first state.
            loop_includes_initial (boolean): If no initial state was defined in
                the machine, setting this to True will cause the _initial state
                placeholder to be included in the added transitions. This argument
                has no effect if the states argument is passed without the
                initial state included.
            conditions (str or list): Condition(s) that must pass in order
                for the transition to take place. Either a list providing the
                name of a callable, or a list of callables. For the transition
                to occur, ALL callables must return True.
            unless (str or list): Condition(s) that must return False in order
                for the transition to occur. Behaves just like conditions arg
                otherwise.
            before (str or list): Callables to call before the transition.
            after (str or list): Callables to call after the transition.
            prepare (str or list): Callables to call when the trigger is activated
            **kwargs: Additional arguments which can be passed to the created transition.
                This is useful if you plan to extend Machine.Transition and require more parameters.
        """
        if states is None:
            states = list(self.states.keys())  # need to listify for Python3
        len_transitions = len(states)
        if len_transitions < 2:
            raise ValueError("Can't create ordered transitions on a Machine "
                             "with fewer than 2 states.")
        if not loop:
            len_transitions -= 1
        # ensure all args are the proper length
        conditions = _prep_ordered_arg(len_transitions, conditions)
        unless = _prep_ordered_arg(len_transitions, unless)
        before = _prep_ordered_arg(len_transitions, before)
        after = _prep_ordered_arg(len_transitions, after)
        prepare = _prep_ordered_arg(len_transitions, prepare)
        # reorder list so that the initial state is actually the first one
        try:
            idx = states.index(self._initial)
            states = states[idx:] + states[:idx]
            first_in_loop = states[0 if loop_includes_initial else 1]
        except ValueError:
            # since initial is not part of states it shouldn't be part of the loop either
            first_in_loop = states[0]

        for i in range(0, len(states) - 1):
            self.add_transition(trigger, states[i], states[i + 1],
                                conditions=conditions[i],
                                unless=unless[i],
                                before=before[i],
                                after=after[i],
                                prepare=prepare[i],
                                **kwargs)
        if loop:
            self.add_transition(trigger, states[-1],
                                # omit initial if not loop_includes_initial
                                first_in_loop,
                                conditions=conditions[-1],
                                unless=unless[-1],
                                before=before[-1],
                                after=after[-1],
                                prepare=prepare[-1],
                                **kwargs)
def add_ordered_transitions ( self , states = None , trigger = 'next_state' , loop = True , loop_includes_initial = True , conditions = None , unless = None , before = None , after = None , prepare = None , * * kwargs ) : if states is None : states = list ( self . states . keys ( ) ) # need to listify for Python3 len_transitions = len ( states ) if len_transitions < 2 : raise ValueError ( "Can't create ordered transitions on a Machine " "with fewer than 2 states." ) if not loop : len_transitions -= 1 # ensure all args are the proper length conditions = _prep_ordered_arg ( len_transitions , conditions ) unless = _prep_ordered_arg ( len_transitions , unless ) before = _prep_ordered_arg ( len_transitions , before ) after = _prep_ordered_arg ( len_transitions , after ) prepare = _prep_ordered_arg ( len_transitions , prepare ) # reorder list so that the initial state is actually the first one try : idx = states . index ( self . _initial ) states = states [ idx : ] + states [ : idx ] first_in_loop = states [ 0 if loop_includes_initial else 1 ] except ValueError : # since initial is not part of states it shouldn't be part of the loop either first_in_loop = states [ 0 ] for i in range ( 0 , len ( states ) - 1 ) : self . add_transition ( trigger , states [ i ] , states [ i + 1 ] , conditions = conditions [ i ] , unless = unless [ i ] , before = before [ i ] , after = after [ i ] , prepare = prepare [ i ] , * * kwargs ) if loop : self . add_transition ( trigger , states [ - 1 ] , # omit initial if not loop_includes_initial first_in_loop , conditions = conditions [ - 1 ] , unless = unless [ - 1 ] , before = before [ - 1 ] , after = after [ - 1 ] , prepare = prepare [ - 1 ] , * * kwargs )