Example #1
0
 def addFormulaData(self):
     dochand=dh.DocumentHandler()       
     doc=dochand.createWriterDocument()
     text = doc.Text
     #text.insertString("this is the statement")
     query = self.capitalisePython(doc)
     communicator = com.APICommunicator()                #create the communicator
     communicator.setConfiguration()                     #set the configuartion using config file
     communicator.checkConfiguration()                   #check whether the configuration is ok
     communicator.getResult(query)                       #query from wolfram API
     fileName = query+".txt"                             
     resultReader = wp.WolframMathResultReader(fileName) #read the stored result
     resultReader.getTotalResult()                       #get all the resources related to the result
     #resultReader.parseWolframResultToLibre()           #the parsing is not happening yet
                       #create the document
     text = doc.Text
     cursor = text.createTextCursor()
     for res in resultReader.plainTexts:                 #add formulas
         try:
             dochand.addFormulaToWriterDocument(doc,cursor,res)
             text.insertString( cursor, "\n\n", 0 )
         except Exception:
             print(res)  
     for img in resultReader.imageFileNames:             #add images to the document
         try:
             imageUrl = "file://"+os.path.dirname(__file__)+"/"+img
             dochand.addImageToWriterDocument(doc,cursor, imageUrl)
             text.insertString( cursor, "\n\n", 0 )
         except Exception:
             print(img)