def reCalculateScores(self, topic): """ Function to get all the Unread Articles and calculate their scores under the given topic. """ print "calculating New article scores for %s" % topic.title pri = prioritizer.Prioritizer(topic) scoreItemsList = pri.listScoreItems() # scoreItemList = [scoreItem for scoreItem in scoreItemsList if scoreItem.item.isUnread is True] pri.setScores(scoreItemsList) print "calculated New article scores for %s" % topic.title self.status = "Calculated New article scores for %s" % topic.title self.sendNotification()
def setNewItemScores(self): """ Function to get the New Articles and calculate their scores under all the topics """ #get all the topics topicsList = classifier.listTopics() for topic in topicsList: pri = prioritizer.Prioritizer(topic) scoreItemsList = pri.listScoreItems() scoreItemList = [scoreItem for scoreItem in scoreItemsList if scoreItem.item.age is 0] pri.setScores(scoreItemList) print "calculated New article scores for %s" % topic.title
def displayUnread(self): """ function to update the Unread Articles list according to the selected feeds list. """ selectedFeedIndex = self.ui.comboFeed.currentIndex() selectedTopicIndex = self.ui.comboTopic.currentIndex() self.currentTopic = self.topicList[selectedTopicIndex] print self.currentTopic if len(self.feedList) == 0: self.scoreItemList = [] else: if selectedFeedIndex == len(self.feedList): pri = prioritizer.Prioritizer(self.currentTopic) self.scoreItemList = pri.listScoreItems() # Now filter out the Old items using a generator #this is being done in the prioritizer now # self.scoreItemList = [scoreItem for scoreItem in self.scoreItemList if scoreItem.item.isUnread is True] # prioritize the list according to the scores self.scoreItemList = pri.prioritize(self.scoreItemList) windowTitle = "All Feeds - feedIO" self.setWindowTitle(windowTitle) else: selectedFeed = self.feedList[selectedFeedIndex] pri = prioritizer.Prioritizer(self.currentTopic) self.scoreItemList = pri.listScoreItems(selectedFeed) # Now filter out the items for the current Feed using a generator #this is being done in the prioritizer now # self.scoreItemList = [scoreItem for scoreItem in self.scoreItemList if (scoreItem.item.feed is selectedFeed and scoreItem.item.isUnread is True)] self.scoreItemList = pri.prioritize(self.scoreItemList) #Code to change the window title to the currently viewing feed's title windowTitle = selectedFeed.title + " - feedIO" self.setWindowTitle(windowTitle) self.ui.listUnread.clear() itemIcon = QIcon() itemIcon.addPixmap(QPixmap(":/images/article.png"), QIcon.Normal, QIcon.Off) # Sort self.scoreItemList according to "isNew" property as primary # Secondary sort it by isUnread # Then sort it according to Score # then sort it according to the Article date. for scoreItem in self.scoreItemList: # treeItem=QTreeWidgetItem([ str(scoreItem.score), scoreItem.item.title]) treeItem = QTreeWidgetItem([ scoreItem.item.title, ]) treeItem.article = scoreItem.item treeItem.setIcon(0, itemIcon) # # Set a part of the article text as the tooltip of Items # itemTip = purify.cleanText(str(scoreItem.score)) itemTip = "Score: <b>" + str( scoreItem.score ) + "</b> " + "<br>Topic: " + "<i>" + scoreItem.topic.title + "</i>" + "<br>Via: " + "<i>" + scoreItem.item.feed.title + "</i>" # tip = purify.shorten(itemTip, 200) treeItem.setToolTip(0, itemTip) if scoreItem.item.age is 0: treeItem.setFont(0, self.newFont) treeItem.setTextColor(0, self.newColor) elif scoreItem.item.age is 1: treeItem.setFont(0, self.unreadFont) treeItem.setTextColor(0, self.unreadColor) else: treeItem.setFont(0, self.readFont) treeItem.setTextColor(0, self.readColor) self.ui.listUnread.addTopLevelItem(treeItem) self.ui.listOld.setFocus()