view backend/AbstractBackend.py @ 197:e604c32f67aa

normalize the published date if the feed contains none
author dirk
date Tue, 24 Jan 2012 10:08:45 +0100
parents 3bcf39181f6e
children f74fe7cb5091
line wrap: on
line source


from datetime import datetime, timedelta

class AbstractBackend(object):
    def __init__(self):
        self.feeds = []
        self.selectedFeed = None
        self.feedEntries = None
        self.selectedFeedEntry = None

    def dispose(self):
        pass

    #
    # handling of feeds
    #

    def selectFeed(self, index):
        self.selectedFeed = self.feeds[index]
        self.feedEntries = None
        return self.selectedFeed

    def entriesForSelectedFeed(self):
        if self.feedEntries is None:
            hideReadEntries = self.preferences().hideReadFeedEntries()
            self.feedEntries = self._retrieveEntriesForSelectedFeed(hideReadEntries)
        return self.feedEntries

    def _calculateExpireDate(self):
        now = datetime.now()
        daysToKeepFeedEntries = self.preferences().daysToKeepFeedEntries()
        delta = timedelta(days=daysToKeepFeedEntries)
        return now - delta

    #
    # handling of the selected feed entry
    #

    def selectFeedEntry(self, index):
        self.selectedFeedEntry = self.feedEntries[index]
        self._markSelectedFeedEntryRead()
        return self.selectedFeedEntry