Exemplo n.º 1
0
 def test_make_cat_start_compile(self):
     ac = AimlCreator()
     expected_aiml = ac.make_cat_star()
     # print('EXPECTED:\n{}'.format(expected_aiml))
     test_aiml = Storage.compileToAIML(str(expected_aiml))
     # print('TEST:\n{}'.format(test_aiml))
     self.assertEqual(str(test_aiml), str(expected_aiml))
Exemplo n.º 2
0
    def onCompile(self):
        if DEBUG: print("Compile Pressed!!!")
        str_to_parse = self.editSpace.editSpace.toPlainText(
        )  # Grabs text from the text display
        if DEBUG: print("text to compile:\n{}".format(str_to_parse))
        if str_to_parse.isspace():
            handleError(
                "There is nothing to compile. You must at least have one tag pair to successfully compile your work."
            )
            return
        try:
            aiml = Storage.compileToAIML(str_to_parse)
            if aiml == -1:
                if DEBUG: print("did not compile properly")
                return
            if DEBUG: print("compiling complete")

            # clearing before updating graph view.
            if DEBUG: print("Clearing scene")
            self.editSpace.graphview.scene.clear()
            self.editSpace.graphview.scene.grScene.clear()

            # Updating code editor
            self.editSpace.aiml = aiml
            if DEBUG: print(f"new model for the aiml:\n{self.editSpace.aiml}")

            for cat in self.editSpace.aiml.tags:
                self.editSpace.create_category_graph_view(
                    cat)  # Sending categories to be drawn on graph view
            if DEBUG: print("finished redrawing nodes")

            self.editSpace.up_to_date = True
            if DEBUG: print("set up_to_date to True")

            self.editSpace.tabs.setStyleSheet('')
            if DEBUG: print("set style sheet for tabs.")

            # Display dialog
            compileSuccessful()
        except Exception as ex:
            print("Exception caught trying to compile project")
            print(ex)
            handleError(ex)