Esempio n. 1
0
    def outputList(self, returnvalue, line):
        return_list = returnvalue.Payload.List
        metaData_list = returnvalue.Description.List
        # print metaData_list
        # metaData = returnvalue.Description.MetaData
        try:
            # print "length:", len(return_list), len(description_list)
            pass
        except:
            pass

        self.oldRowCount = self.Universe.Body.rowCount()

        # i = 0
        for i in range(len(return_list)):
            current_item = QtGui.QTableWidgetItem(return_list[i])
            try:
                # current_description = description_list[i]
                current_metadata = metaData_list[i]
            except TypeError:
                print "ERROR: WRONG METADATA COUNT AT ", i
                # current_description = None
                current_metadata = MetaData()
                current_metadata.Language = "default"
            i += 1
            self.Universe.Body.insertRow(self.rowcount + i)
            self.Universe.Body.setItem(self.rowcount + i, 0, current_item)
            # print "outputHandler:", current_metadata.ExecuteCommand, current_metadata.Language
            self.Universe.Body.setDescription(self.rowcount + i, 0, current_metadata)  # current_description)
            i -= 1
            # self.Universe.Body.setItem(self.rowcount+i, 1, QtGui.QTableWidgetItem(unicode(mime_value[i])))

        # if returnvalue[1] > -1:
        self.Universe.Body.setCurrentCell(self.oldRowCount + int(line) - 1, 0)
Esempio n. 2
0
 def resultInTable(self, head, result, metaLanguage, name):
     try:
         result_first_element = result[0]
     except:
         self.ResultObject.Payload.String = "kein Ergebnis gefunden"
         return self.ResultObject
     else:
         table = SpeakingTableWidget(len(result), len(result_first_element), self.Universe, name)
         
         table.setHorizontalHeaderLabels(head)
         #return table, "bla"
         
         row = -1
         for line in result:
             row += 1
             
             column = -1
             for item in line:
                 column += 1
                 
                 table.setItem(row, column, QtGui.QTableWidgetItem(unicode(item)) )
                 metaData = MetaData()
                 metaData.Language = metaLanguage[column]
                 table.setDescription(row, column, metaData)
                 
                 #print item, metaData.Language
         
         table.resizeColumnsToContents()
         
         self.ResultObject.Payload.SpeakingTableWidget = table
         return self.ResultObject
Esempio n. 3
0
 def readVerseRange(self, book, chapter, verses):
     start_verse, stop_verse = int(verses[0]), int(verses[1])
     
     if start_verse > stop_verse:
         start_verse, stop_verse = stop_verse, start_verse
     
     print "READ VERSE RANGE", book, chapter, verses
     
     result_list = []
     metaData_list = []
     for verse in range(start_verse, stop_verse+1):
         metaData = MetaData()
         metaData.Language = self.language
         metaData_list.append(metaData)
         
         result = self.readOneVerse(book, chapter, verse)
         #if resultObject.Error.Message:
         #    return resultObject
         #else:
         result_list.append(unicode(verse) + " " + result)
     
     #self.ResultObject.Payload.String = None
     #self.ResultObject.Payload.List = result_list
     #self.ResultObject.Description.List = metaData_list
     #return self.ResultObject
     
     return result_list
Esempio n. 4
0
 def openSongbook(self, args):
     #ResultObject = createResultObject.getObject()
     
     path = self.SONGBOOKFILE
     
     if path == None:
         self.ResultObject.Error.Message = "songbookfile not found"
         return self.ResultObject
     
     base, dirs, files = iter(os.walk( path )).next()
     
     dirs.sort()
     files.sort()
     
     #description_list = []
     metaData_list = []
     for item in dirs:
         #description_list.append("songbook/changeSongdir")
         pass
         
     for item in files:
         dirs.append(item)
         #description_list.append("songbook/song")
         metaData = MetaData()
         metaData.Language = "default"
         metaData.ExecuteCommand = "song %CONTENT%"
         
         metaData_list.append(metaData)
     
     self.ResultObject.Payload.List = dirs
     #self.ResultObject.Description.List = description_list
     self.ResultObject.Description.List = metaData_list
     return self.ResultObject
Esempio n. 5
0
	def searchResultFormatter(self, result):
		metaData = MetaData()
		metaData_list = []
		result_list = [str(len(result)) + " Ergebnisse gefunden"]
		metaData.Language = "de"
		metaData_list.append(metaData)
		
		for i in range (0, len(result)):
			metaData1 = MetaData()
			metaData2 = MetaData()
			
			res1 = unicode(result[i][0])
			
			d = self.getBooks()
			for k in d:
				if d[k] == res1:
					res1 = k#.decode("utf8")
					
			res2 = unicode(result[i][1])
			res3 = unicode(result[i][2])
			result_helper = unicode(result[i][3])
			result_list.append(res1 + " " + res2 + "," + res3)
			metaData1.ExecuteCommand = "%CONTENT%"
			metaData_list.append(metaData1)
			#mime_list.append("bible/pos")
			#result_list.append(res1 + " kapitel " + res2 + " vers " + res3)
			result_list.append(result_helper)
			
			metaData_list.append(metaData2)
				
		self.ResultObject.Payload.List = result_list
		self.ResultObject.Description.List = metaData_list
		return self.ResultObject
Esempio n. 6
0
 def setDescription(self, x, y, description):
     print x, y, description
     
     metadata = MetaData()
     try:
         metadata.ExecuteCommand = description.ExecuteCommand
     except:
         metadata.ExecuteCommand = "ERROR: SpeakingTableWidget -> setDescription"
     self.description_list[x][y] = description
Esempio n. 7
0
 def readOneVerse(self, book_number, chapter, verse):
     book_names = self.bookNamesDict()
     print "BOOK NUMBER", book_number
     if book_number:
         book_name = book_names[int(book_number)]
     else:
         self.ResultObject.Error.Message = "Buch nicht gefunden"
         return self.ResultObject
     
     module = ZModule(self.sword_module_name, self.modules_path)
     try:
         try:
             result = module.text_for_ref(book_name, chapter, verse)
         except ValueError:
             "EXAMPLE: 1mose 1-4"
             self.ResultObject.Error.Message = "Bitte nur ein Kapitel angeben"
             return self.ResultObject
         except TypeError:
             self.ResultObject.Error.Message = "ausgewaehltes Bibelmodul nicht verfuegbar. Versuchen Sie es evtl. klein zu schreiben."
             return self.ResultObject
         
     except IndexError:
         self.ResultObject.Error.Message = "Kapitel existiert nicht"
         return self.ResultObject
     else:
         self.history.historyWrite(str(book_number) + " " + str(chapter) )
         
         "ensure correct character encoding"
         try:
             #print "sword -> result: ", result
             result = result.decode("utf8")
         except:
             result = result.decode("iso-8859-1")
         
         try:
             bible_text, title_text, note_text = self.SwordParser.feed(result)
         except Exception, e:
             print "ERROR WHILE PARSING: ", e
         
         metaData = MetaData()
         metaData.Language = self.language
         
         #self.ResultObject.Payload.String = bible_text
         #self.ResultObject.Description.MetaData = metaData
         #return self.ResultObject
         return bible_text
Esempio n. 8
0
    def insertInputLine(self, input):
        self.rowcount = self.Universe.Body.rowCount()
        inputItem = QtGui.QTableWidgetItem(unicode("%input% " + input))  # .decode("utf8")))

        self.Universe.Body.insertRow(self.rowcount)
        # self.Universe.Body.setItem(self.rowcount, 0, inputItem)
        ##self.Universe.Body.appendRow(inputItem, "inputline")
        # self.Universe.Body.setDescription(self.rowcount, 0, "input")
        metaData = MetaData()
        metaData.Language = "default"
        metaData.ExecuteCommand = input
        self.Universe.Body.setData(self.rowcount, 0, inputItem, metaData)

        font = QtGui.QFont()
        font.setPointSize(12)
        font.setWeight(75)
        font.setUnderline(False)
        # font.setItalic(True)
        # font.set
        self.Universe.Body.item(self.rowcount, 0).setFont(font)
Esempio n. 9
0
    def outputLine(self, returnvalue):
        return_line = returnvalue.Payload.String
        # description = returnvalue.Description.String
        metaData = returnvalue.Description.MetaData
        try:
            # metaData.ExecuteCommand
            metaData.Language
        except:
            metaData = MetaData()
            # metaData.ExecuteCommand = None
            metaData.Language = "default"
        self.oldRowCount = self.Universe.Body.rowCount()

        returnItem = QtGui.QTableWidgetItem(return_line.decode("utf8"))
        self.Universe.Body.insertRow(self.rowcount + 1)
        # self.Universe.Body.appendRow(returnItem, None)
        self.Universe.Body.setItem(self.rowcount + 1, 0, returnItem)
        self.Universe.Body.setDescription(self.rowcount + 1, 0, metaData)  # None)#description)

        self.Universe.Body.setCurrentCell(self.rowcount + 1, 0)
        self.Universe.Body.scrollToItem(returnItem)
Esempio n. 10
0
	def books(self):
		books = self.getBookList()
		numbers = self.getBookListNumbers()
		
		output = []
		metaData_list = []
		for i in range (0, len(books)):
			output.append( unicode( books[i] ) + " " + unicode( numbers[i] ) )
			#mime_list.append("command/bible")
			
			metaData = MetaData()
			metaData.Language = "default"
			metaData.ExecuteCommand = "%CONTENT%"
			
			metaData_list.append(metaData)
			
		#books = self.getBookList()
		
		self.ResultObject.Payload.List = output
		self.ResultObject.Description.List = metaData_list
		return self.ResultObject
Esempio n. 11
0
    def outputError(self, error):
        self.oldRowCount = self.Universe.Body.rowCount()

        returnItem = QtGui.QTableWidgetItem(error.decode("utf8"))
        self.Universe.Body.insertRow(self.rowcount + 1)
        # self.Universe.Body.setItem(self.rowcount+1, 0, returnItem)

        metaData = MetaData()
        metaData.Language = "default"
        metaData.ExecuteCommand = None
        # self.Universe.Body.setDescription(self.rowcount+1, 0, metaData)
        self.Universe.Body.setData(self.rowcount + 1, 0, returnItem, metaData)

        self.Universe.Body.setCurrentCell(self.rowcount + 1, 0)
        self.Universe.Body.scrollToItem(returnItem)

        font = QtGui.QFont()
        font.setBold(True)

        self.Universe.Body.item(self.rowcount + 1, 0).setFont(font)
        self.Universe.Body.item(self.rowcount + 1, 0).setTextColor(QtGui.QColor("red"))
        self.Universe.Body.item(self.rowcount + 1, 0).setBackgroundColor(QtGui.QColor("white"))
Esempio n. 12
0
 def books(self, c, a):
     bituza = Bituza(self.Universe)
     books = bituza.getBookList()
     
     numbers = [50, 40, 27, 36, 34, 24, 21, 4, 31, 24, 22, 25, 29, 36, 10, 13, 10, 42, 150, 31, 12, 8, 66, 52, 5, 48, 12, 14, 3, 9, 1, 4, 7, 3, 3, 3, 2, 14, 4, 28, 16, 24, 21, 28, 16, 16, 13, 6, 6, 4, 4, 5, 3, 6, 4, 3, 1, 13, 5, 5, 3, 5, 1, 1, 1, 22]
     
     output = []
     metaData_list = []
     for i in range (0, len(books)):
         output.append( unicode( books[i] ) + " " + unicode( numbers[i] ) )
         #mime_list.append("command/bible")
         
         metaData = MetaData()
         metaData.Language = "default"
         metaData.ExecuteCommand = "%CONTENT%"
         
         metaData_list.append(metaData)
         
     #books = self.getBookList()
     
     self.ResultObject.Payload.List = output
     self.ResultObject.Description.List = metaData_list
     return self.ResultObject