Пример #1
0
 def findExamplesUsingJishoClient(self):
     self.searchResult.clear()
     
     lookup = JishoClient.getExamples(self.possibleReading.text())
     if lookup is not None:
         for item in lookup:
             self.searchResult.append('<b>' + item +'</b><br/>' + lookup[item] + '<br/>')
         
     self.adjustSize()
Пример #2
0
 def run(self):
     print "Imma in yȯr background, updating yȯrz db"
     while not self.event.is_set():
         if self.mayUpdate and self.hasItemsToUpdate:
             item = self.dbUpdater.getSomeItem()
             if item is None:
                 self.hasItemsToUpdate = False
                 print "No more items to update"
             else:
                 self.dbUpdater.addExamples(item, JishoClient.getExamples(item.character))
                 #                    print 'Added examples for ' + item.character
                 print "Attempted to add examples for " + item.character
         self.event.wait(self.waitFor)
Пример #3
0
    def getCurrentExample(self):
        if not self.db.checkIfKanjiHasExamples(self.currentItem):
            #NB: how about some threading and queues?
            self.db.addExamplesForKanji(self.currentItem, JishoClient.getExamples(self.currentItem.character))

        self.currentExample = self.db.getExample(self.currentItem)
        if self.currentExample is not None:
            ## adding corresponding word to db
            #self.db.addWordToDb(self.currentItem, self.getWordFromExample())
            self.db.addWordToDbAndLinkToExample(self.currentItem, self.getWordFromExample(), self.currentExample)
            
            return self.currentExample.sentence
        else:
            return self.currentExample