a decorator for transitioning from certain states to a target state. must be used on bound methods of a class
    instance, only.
171422
def event(from_states=None, to_state=None):
    
    from_states_tuple = (from_states, ) if isinstance(from_states, State) else tuple(from_states or [])
    if not len(from_states_tuple) >= 1:
        raise ValueError()
    if not all(isinstance(state, State) for state in from_states_tuple):
        raise TypeError()
    if not isinstance(to_state, State):
        raise TypeError()

    def wrapper(wrapped):

        @functools.wraps(wrapped)
        def transition(instance, *a, **kw):
            if instance.current_state not in from_states_tuple:
                raise InvalidStateTransition()
            try:
                result = wrapped(instance, *a, **kw)
            except Exception as error:
                error_handlers = getattr(instance, '___pystatemachine_transition_failure_handlers', [])
                for error_handler in error_handlers:
                    error_handler(instance, wrapped, instance.current_state, to_state, error)
                if not error_handlers:
                    raise error
            else:
                StateInfo.set_current_state(instance, to_state)
                return result

        return transition

    return wrapper
559615
def transition(prior_state, next_state):
    
    if next_state not in STATES[prior_state][TRANSITION]:
        acceptable = STATES[prior_state][TRANSITION]
        err = "cannot {}->{} may only {}->{}".format(prior_state,
                                                     next_state,
                                                     prior_state,
                                                     acceptable)
        raise InvalidStateTransition(err)
    return next_state
287509
def rule_for(self, target_class):
        
        def decorator(rule_class):
            self.add_rule(rule_class, target_class)
            return rule_class
        return decorator
111906
function refreshState(){
		self._possibleTransitions = [];
		for(var transitionIndex = 0; transitionIndex < self._states[self._currentState].transitions.length; ++transitionIndex){
			var transition = self._states[self._currentState].transitions[transitionIndex];
			// Initialize the new variable that we'll push() onto _possibleTransitions later.
			var possibleTransition = {
				destination: transition.destination,
				action: transition.action,
				outputEventType: transition.outputEventType,
				remainingEvents: []
			};
			// Populate the list of remaining events that will be subsequently decreased, until it hits a count of zero, at which point this particular transition takes place.
			for(var eventIndex = 0; eventIndex < transition.requiredEvents.length; ++eventIndex){
				// Place the event specification into the list of remaining events.
				var event = transition.requiredEvents[eventIndex];
				possibleTransition.remainingEvents.push(event);
			}
			// Now that the transition specification is complete, add it to the list of transitions possible from the current state.
			self._possibleTransitions.push(possibleTransition);
			// Additionally, if the spec contained an outputEventType (which overrides SagaStateTransitioned for initiating transitions), register a handler for that event type.
			if(possibleTransition.outputEventType){
				// Duplicate handlers are checked, in order to avoid double state refresh (which would result in excessive event handler populations -> memory leak via avalanche effect after a few transitions).
				//  This check is somewhat strange due to EventEmitter's listener function wrapping when using once().
				if(!self.listeners(possibleTransition.outputEventType).some(function(listenerFunction){ return listenerFunction === applyTransition || listenerFunction.listener === applyTransition; })){
					// The listener is not yet present, so add it.
					self.once(possibleTransition.outputEventType, applyTransition);
				}
			}
		}
	}
610159
async def _run_state(self, responder, state, trigger, request) \
            -> BaseState:
        

        user_trigger = trigger

        # noinspection PyBroadException
        try:
            if trigger:
                await state.handle()
            else:
                await state.confused()

            for i in range(0, settings.MAX_INTERNAL_JUMPS + 1):
                if i == settings.MAX_INTERNAL_JUMPS:
                    raise MaxInternalJump()

                trigger, state_class, dnr = \
                    await self._find_trigger(request, state.name(), True)

                if not trigger:
                    break

                logger.debug('Jumping to state: %s', state_class.name())
                state = state_class(request, responder, trigger, user_trigger)
                await state.handle()
        except Exception:
            logger.exception('Error while handling state "%s"', state.name())
            responder.clear()
            reporter.report(request, state.name())
            await state.error()

        return state
1233033
def transition_to(path, current_state=self.current_state)
      path = path.to_s
      state = current_state || self
      exit_states = []

      # Find the nearest parent state on the path of the current state which
      # has a sub-state at the given path
      new_states = state.find_states(path)
      while(!new_states) do
        exit_states << state
        state = state.parent_state
        raise(StateNotFound, transition_error(path)) unless state
        new_states = state.find_states(path)
      end

      # The first time we enter a state, the state_manager gets entered as well
      new_states.unshift(self) unless has_state?

      # Can only transition to leaf states
      # TODO: transition to the initial_state of the state?
      raise(InvalidTransition, transition_error(path)) unless new_states.last.leaf?

      enter_states = new_states - exit_states
      exit_states = exit_states - new_states

      from_state = current_state
      # TODO: does it make more sense to throw an error instead of allowing
      # a transition to the current state?
      to_state = enter_states.last || from_state

      run_before_callbacks(from_state, to_state, current_event, enter_states, exit_states)

      # Set the state on the underlying resource
      self.current_state = to_state

      run_after_callbacks(from_state, to_state, current_event, enter_states, exit_states)
    end
6084
def add_full_state_methods(class_with_globalize_methods):
    
    assert hasattr(class_with_globalize_methods, 'active_set')
    assert hasattr(class_with_globalize_methods, 'nstates_full')

    for name, method in class_with_globalize_methods.__dict__.copy().items():
        if isinstance(method, property) and hasattr(method.fget, '_map_to_full_state_def_arg'):
            default_value = method.fget._map_to_full_state_def_arg
            axis = method.fget._map_to_full_state_along_axis
            new_getter = _wrap_to_full_state(name, default_value, axis)
            alias_to_full_state_inst = property(new_getter)
        elif hasattr(method, '_map_to_full_state_def_arg'):
            default_value = method._map_to_full_state_def_arg
            axis = method._map_to_full_state_along_axis
            alias_to_full_state_inst = _wrap_to_full_state(name, default_value, axis)
        else:
            continue

        name += "_full_state"
        setattr(class_with_globalize_methods, name, alias_to_full_state_inst)

    return class_with_globalize_methods
557258
function(options) {
        this._transitions = {}
        this._states = {}
        options = options || {}
        this._bindStates()
        this._bindTransitions()
        if (options.debugStateMachine === true)
          StateMachine.DebugView.register(this)
        this.bind('all', this._onMachineEvent, this)
        this.currentState = INIT_STATE
        this.startStateMachine = function() {
          throw new Error('startStateMachine has been called twice!')
        }
      }
25391
private static Transition makeTransitionToSelf(Pattern regex) {
    return new Transition(regex) {
      @Override
      Context computeNextContext(Context prior, Matcher matcher) {
        return prior;
      }
    };
  }
932912
function(moveData) {
            var self            = this,
                transitionRules = [],
                transformValues = [],
                isResizing      = self.mixer.config.animation.animateResizeTargets,
                isFading        = typeof self.mixer.effectsIn.opacity !== 'undefined';

            self.callActions('beforeApplyStylesOut', arguments);

            // Build the transition rules

            transitionRules.push(self.writeTransitionRule(
                mixitup.features.transformRule,
                moveData.staggerIndex
            ));

            if (moveData.statusChange !== 'none') {
                transitionRules.push(self.writeTransitionRule(
                    'opacity',
                    moveData.staggerIndex,
                    moveData.duration
                ));
            }

            if (isResizing) {
                transitionRules.push(self.writeTransitionRule(
                    'width',
                    moveData.staggerIndex,
                    moveData.duration
                ));

                transitionRules.push(self.writeTransitionRule(
                    'height',
                    moveData.staggerIndex,
                    moveData.duration
                ));

                transitionRules.push(self.writeTransitionRule(
                    'margin',
                    moveData.staggerIndex,
                    moveData.duration
                ));
            }

            // If no callback was provided, the element will
            // not transition in any way so tag it as "immovable"

            if (!moveData.callback) {
                self.mixer.targetsImmovable++;

                if (self.mixer.targetsMoved === self.mixer.targetsImmovable) {
                    // If the total targets moved is equal to the
                    // number of immovable targets, the operation
                    // should be considered finished

                    self.mixer.cleanUp(moveData.operation);
                }

                return;
            }

            // If the target will transition in some fasion,
            // assign a callback function

            self.operation = moveData.operation;
            self.callback = moveData.callback;

            // As long as the target is not excluded, increment
            // the total number of targets bound

            !self.isExcluded && self.mixer.targetsBound++;

            // Tag the target as bound to differentiate from transitionEnd
            // events that may come from stylesheet driven effects

            self.isBound = true;

            // Apply the transition

            self.applyTransition(transitionRules);

            // Apply width, height and margin negation

            if (isResizing && moveData.posOut.width > 0 && moveData.posOut.height > 0) {
                self.dom.el.style.width        = moveData.posOut.width + 'px';
                self.dom.el.style.height       = moveData.posOut.height + 'px';
                self.dom.el.style.marginRight  = moveData.posOut.marginRight + 'px';
                self.dom.el.style.marginBottom = moveData.posOut.marginBottom + 'px';
            }

            if (!self.mixer.config.animation.nudge && moveData.statusChange === 'hide') {
                // If we're not nudging, the translation should be
                // applied before any other transforms to prevent
                // lateral movement

                transformValues.push('translate(' + moveData.posOut.x + 'px, ' + moveData.posOut.y + 'px)');
            }

            // Apply fade

            switch (moveData.statusChange) {
                case 'hide':
                    isFading && (self.dom.el.style.opacity = self.mixer.effectsOut.opacity);

                    transformValues = transformValues.concat(self.mixer.transformOut);

                    break;
                case 'show':
                    isFading && (self.dom.el.style.opacity = 1);
            }

            if (
                self.mixer.config.animation.nudge ||
                (!self.mixer.config.animation.nudge && moveData.statusChange !== 'hide')
            ) {
                // Opposite of above - apply translate after
                // other transform

                transformValues.push('translate(' + moveData.posOut.x + 'px, ' + moveData.posOut.y + 'px)');
            }

            // Apply transforms

            self.dom.el.style[mixitup.features.transformProp] = transformValues.join(' ');

            self.callActions('afterApplyStylesOut', arguments);
        }
24178
function(position, target, name, decorator) {
		target[name] = gui.Combo[position](decorator)(target[name]);
		return target;
	}
652522
def ensure_state(default_getter, exc_class, default_msg=None):
    """"""
    def decorator(getter=default_getter, msg=default_msg):
        def ensure_decorator(f):
            @wraps(f)
            def inner(self, *args, **kwargs):
                if not getter(self):
                    raise exc_class(msg) if msg else exc_class()
                return f(self, *args, **kwargs)
            return inner
        return ensure_decorator
    return decorator
519453
def transition_function(self, qi, u):
        
        try:
            return self.transition[qi][u]
        except KeyError:
            if u in self.alphabet:
                try:
                    return self.transition[qi]['*']
                except KeyError:
                    return None
            return None
281221
def add_transition(self, output,
                       probability_func=lambda index: np.ones(len(index), dtype=float),
                       triggered=Trigger.NOT_TRIGGERED):
        
        t = Transition(self, output, probability_func=probability_func, triggered=triggered)
        self.transition_set.append(t)
        return t
174907
def transition_state(state)
      authorize @contribution
      @initiative = @contribution.initiative
      @user = @contribution.user
      state = state.to_sym
      transition = @contribution.transition_by_state(state)
      initial_state = @contribution.state_name
      resource_name = @contribution.class.model_name.human
      if @contribution.send("can_#{transition}?")
        begin
          if @contribution.state_on_gateway != state
            if @contribution.update_state_on_gateway!(state)
              @contribution.send("#{transition}!")
            else
              flash[:alert] = t('flash.actions.update.alert', resource_name: resource_name)
            end
          else
            @contribution.send("#{transition}!")
          end
        rescue
          flash[:alert] = t('flash.actions.update.alert', resource_name: resource_name)
        end
      else
        flash[:alert] = t('flash.actions.update.alert', resource_name: resource_name)
      end
      if flash[:alert].present?
        render 'initiatives/contributions/show'
      else
        if initial_state == :pending
          flash[:notice] = t('flash.actions.create.notice', resource_name: resource_name)
        else
          flash[:notice] = t('flash.actions.update.notice', resource_name: resource_name)
        end
        redirect_to initiative_contribution_path(@contribution.initiative.id, @contribution)
      end
    end
1170567
async def make_transition_register(self, request: 'Request'):
        

        register = {}

        for stack in self._stacks:
            register = await stack.patch_register(register, request)

        return register
1341468
protected void transition(Member.Type type) {
    switch (type) {
      case ACTIVE:
        if (!(state instanceof ActiveState)) {
          transition(CopycatServer.State.FOLLOWER);
        }
        break;
      case PASSIVE:
        if (this.state.type() != CopycatServer.State.PASSIVE) {
          transition(CopycatServer.State.PASSIVE);
        }
        break;
      case RESERVE:
        if (this.state.type() != CopycatServer.State.RESERVE) {
          transition(CopycatServer.State.RESERVE);
        }
        break;
      default:
        if (this.state.type() != CopycatServer.State.INACTIVE) {
          transition(CopycatServer.State.INACTIVE);
        }
        break;
    }
  }