def transition(self, role, chooseNextStateIndependentFromRole=False):
        """ Trigger selected transition and return
        message or none if waiting.
        """
#        print "Current state: {}".format(self.mm.getState())
        status = STATUS_NO_TRANSITION
        if chooseNextStateIndependentFromRole:
            roleForNextState = None
        else:
            roleForNextState = role
        # Select transition mode according to mode initialization
        if self.mode == MODE_MOST_PROBABLE_TRANSITION:
            next_state = self.mm.choose_most_probable_next_state(roleForNextState)
        elif self.mode == MODE_LEAST_PROBABLE_TRANSITION:
            next_state = self.mm.choose_least_probable_next_state(roleForNextState)
        elif self.mode == MODE_RANDOM_TRANSITION:
            next_state = self.mm.choose_random_next_state(roleForNextState)
        elif self.mode == MODE_FUZZING_TRANSITION:
            next_state = self.mm.choose_next_state_OFS(roleForNextState, self)
        else:
            raise self.mode % "Unknown mode %d"

        # we first have to check, whether the choosen
        # state is according to our role...
        if not next_state[0].endswith("END"):
            if chooseNextStateIndependentFromRole and not(next_state[0].endswith(role)):
                next_state = None

        (state, template, msg, fields, transition) = self._transition_to_state(next_state)

        if state is not None and state.endswith("END"):
            # since we have reached the END state, no message is generated...
            status = STATUS_END

        if msg is not None:
            # set the state!
            self.templates.append(template)
            print ">>> SELECTED TEMPLATE: {}".format(template.ID)
            self.fields.append(fields)
            self.mm.update_state(state)
            print ">>> TRANSITION TO STATE: {}".format(self.mm.state)
            status = STATUS_OK

        return (status, msg, transition)
dataset/ETHPy150Open hgascon/pulsar/pulsar/core/lens.py/Lens.transition/swapped operands of `%`