Esempio n. 1
0
    def run(self, conversation: Conversation):
        from dialog.elements.goto import Goto
        from dialog.elements.output import Output
        from dialog.elements.action import Action

        handled = False
        conversation.flow_position.append(self._id)
        goto_position = conversation.get_first_goto_position(self)
        if goto_position is not None:
            if goto_position == self._id:
                goto_position = conversation.get_first_goto_position(self)
            else:
                raise Exception()
        if self.grammar.run(conversation):
            for index, child in enumerate(self.children):
                if goto_position is None or index >= goto_position:
                    conversation.flow_position.append(index)
                    if isinstance(child, Action):
                        child.run(conversation)
                    elif isinstance(child, Output):
                        child.run(conversation)
                    elif isinstance(child, Goto):
                        child.run(conversation)
                    else:
                        raise NotImplementedError(type(child))
                    conversation.flow_position.pop()

            handled = True

        conversation.flow_position.pop()
        return handled
Esempio n. 2
0
    def run(self, conversation: Conversation):
        from dialog.elements import Input, Goto, Folder

        goto_position = conversation.get_first_goto_position(self)
        conversation.flow_position.append(self._id)
        if goto_position is None:
            raise GetUserInputException(conversation, self)
        else:
            if goto_position == self._id:
                # so now it needs to look through the possible responses
                goto_position = conversation.get_first_goto_position(self)
            else:
                raise Exception()

            for index, child in enumerate(self.children):
                if goto_position is None or index >= goto_position:
                    conversation.flow_position.append(index)
                    if isinstance(child, Input):
                        # from dialog.runners.input import InputRunner
                        child.run(conversation)
                    elif isinstance(child, Goto):
                        child.run(conversation)
                    elif isinstance(child, Folder):
                        child.run(conversation)
                    else:
                        raise NotImplementedError(type(child))

                    conversation.flow_position.pop()

            conversation.flow_position.pop()
Esempio n. 3
0
    def run(self, conversation: Conversation):
        from dialog.elements.goto import Goto
        from dialog.elements.output import Output
        from dialog.elements.action import Action

        handled = False
        conversation.flow_position.append(self._id)
        goto_position = conversation.get_first_goto_position(self)
        if goto_position is not None:
            if goto_position == self._id:
                goto_position = conversation.get_first_goto_position(self)
            else:
                raise Exception()
        if self.grammar.run(conversation):
            for index, child in enumerate(self.children):
                if goto_position is None or index >= goto_position:
                    conversation.flow_position.append(index)
                    if isinstance(child, Action):
                        child.run(conversation)
                    elif isinstance(child, Output):
                        child.run(conversation)
                    elif isinstance(child, Goto):
                        child.run(conversation)
                    else:
                        raise NotImplementedError(type(child))
                    conversation.flow_position.pop()

            handled = True

        conversation.flow_position.pop()
        return handled
Esempio n. 4
0
    def run(self, conversation: Conversation):
        conversation.flow_position.append(self._id)
        goto_position = conversation.get_first_goto_position(self)
        if goto_position is not None:
            if goto_position == self._id:
                goto_position = conversation.get_first_goto_position(self)
            else:
                raise Exception()
        print("start_folder_runner,_id=%s" % (self._id))
        for index, child in enumerate(self.children):

            if goto_position is None or index >= goto_position:
                conversation.flow_position.append(index)
                if isinstance(child, Output):
                    child.run(conversation)
                elif isinstance(child, Search):
                    child.run(conversation)
                elif isinstance(child, Default):
                    child.run(conversation)
                else:
                    raise NotImplementedError(type(child))

                conversation.flow_position.pop()

        conversation.flow_position.pop()
Esempio n. 5
0
    def run(self, conversation: Conversation):
        conversation.flow_position.append(self._id)
        goto_position = conversation.get_first_goto_position(self)
        if goto_position is not None:
            if goto_position == self._id:
                goto_position = conversation.get_first_goto_position(self)
            else:
                raise Exception()
        print("start_folder_runner,_id=%s" % (self._id))
        for index, child in enumerate(self.children):

            if goto_position is None or index >= goto_position:
                conversation.flow_position.append(index)
                if isinstance(child, Output):
                    child.run(conversation)
                elif isinstance(child, Search):
                    child.run(conversation)
                elif isinstance(child, Default):
                    child.run(conversation)
                else:
                    raise NotImplementedError(type(child))

                conversation.flow_position.pop()

        conversation.flow_position.pop()
Esempio n. 6
0
    def run(self, conversation: Conversation):
        conversation.flow_position.append(self._id)
        goto_position = conversation.get_first_goto_position(self)
        if goto_position is not None:
            if goto_position == self._id:
                goto_position = conversation.get_first_goto_position(self)
            else:
                raise Exception()

        for index, child in enumerate(self.children):
            if goto_position is None or index >= goto_position:
                conversation.flow_position.append(index)
                if isinstance(child, Prompt):
                    child.run(conversation)
                elif isinstance(child, GetUserInput):
                    child.run(conversation)
                elif isinstance(child, Output):
                    child.run(conversation)
                elif isinstance(child, Goto):
                    child.run(conversation)
                elif isinstance(child, Input):
                    child.run(conversation)
                elif isinstance(child, Action):
                    child.run(conversation)
                else:
                    raise NotImplementedError(child)
                conversation.flow_position.pop()

        conversation.flow_position.pop()
Esempio n. 7
0
    def run(self, conversation: Conversation):
        from dialog.elements import Input, Goto, Folder

        goto_position = conversation.get_first_goto_position(self)
        conversation.flow_position.append(self._id)
        if goto_position is None:
            raise GetUserInputException(conversation, self)
        else:
            if goto_position == self._id:
                # so now it needs to look through the possible responses
                goto_position = conversation.get_first_goto_position(self)
            else:
                raise Exception()

            for index, child in enumerate(self.children):
                if goto_position is None or index >= goto_position:
                    conversation.flow_position.append(index)
                    if isinstance(child, Input):
                        # from dialog.runners.input import InputRunner
                        child.run(conversation)
                    elif isinstance(child, Goto):
                        child.run(conversation)
                    elif isinstance(child, Folder):
                        child.run(conversation)
                    else:
                        raise NotImplementedError(type(child))

                    conversation.flow_position.pop()

            conversation.flow_position.pop()
Esempio n. 8
0
    def run(self, conversation: Conversation):
        conversation.flow_position.append(self._id)
        goto_position = conversation.get_first_goto_position(self)
        if goto_position is not None:
            if goto_position == self._id:
                goto_position = conversation.get_first_goto_position(self)
            else:
                raise Exception()

        for index, child in enumerate(self.children):
            if goto_position is None or index >= goto_position:
                conversation.flow_position.append(index)
                if isinstance(child, Prompt):
                    child.run(conversation)
                elif isinstance(child, GetUserInput):
                    child.run(conversation)
                elif isinstance(child, Output):
                    child.run(conversation)
                elif isinstance(child, Goto):
                    child.run(conversation)
                elif isinstance(child, Input):
                    child.run(conversation)
                elif isinstance(child, Action):
                    child.run(conversation)
                else:
                    raise NotImplementedError(child)
                conversation.flow_position.pop()

        conversation.flow_position.pop()
Esempio n. 9
0
    def run(self, conversation: Conversation):
        from dialog.elements import Prompt, GetUserInput, Output, Goto, Action, Input

        conversation.flow_position.append(self._id)
        goto_position = conversation.get_first_goto_position(self)
        if goto_position is not None:
            if goto_position == self._id:
                goto_position = conversation.get_first_goto_position(self)
            else:
                raise Exception()

        search_object = self.dialog.ref_ids[self.ref]
        input_handled = False
        for index, child in enumerate(search_object.children):
            if goto_position is None or index >= goto_position:
                conversation.flow_position.append(index)
                if isinstance(child, Prompt):
                    child.run(conversation)
                elif isinstance(child, GetUserInput):
                    child.run(conversation)
                elif isinstance(child, Output):
                    child.run(conversation)
                elif isinstance(child, Goto):
                    child.run(conversation)
                elif isinstance(child, Action):
                    child.run(conversation)
                elif isinstance(child, Input):
                    if not input_handled:
                        input_handled = child.run(conversation)
                else:
                    raise NotImplementedError(child)
                conversation.flow_position.pop()

        conversation.flow_position.pop()
Esempio n. 10
0
 def run(self, conversation: Conversation):
     # conversation.flow_position.append(flow._id)
     goto_position = conversation.get_first_goto_position(self)
     for index, folder in enumerate(self.folders):
         if goto_position is None or index >= goto_position:
             conversation.flow_position.append(index)
             folder.run(conversation)
             conversation.flow_position.pop()
Esempio n. 11
0
    def run(self, conversation: Conversation):
        conversation.flow_position.append(self._id)
        goto_position = conversation.get_first_goto_position(self)
        if goto_position is not None:
            if goto_position == self._id:
                goto_position = conversation.get_first_goto_position(self)
            else:
                raise Exception()

        for index, child in enumerate(self.children):
            if goto_position is None or index >= goto_position:
                conversation.flow_position.append(index)
                if isinstance(child, Output):
                    child.run(conversation)
                else:
                    # for now seems important to only have default on here
                    raise NotImplementedError(child)
                conversation.flow_position.pop()

        conversation.flow_position.pop()