Mercurial > hg > Feedworm
view backend/AbstractBackend.py @ 259:304917762618 default tip
implementation of feed updates
author | Dirk Olmes <dirk@xanthippe.ping.de> |
---|---|
date | Tue, 12 Mar 2019 02:41:22 +0100 |
parents | f79be01821c4 |
children |
line wrap: on
line source
# -*- coding: utf-8 -*- from datetime import datetime, timedelta def calculateExpireDate(preferences): now = datetime.now() daysToKeepFeedEntries = preferences.daysToKeepFeedEntries() delta = timedelta(days=daysToKeepFeedEntries) return now - delta 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 getFeeds(self): if self.preferences().showOnlyUnreadFeeds(): self.feeds = self.getUnreadFeeds() else: self.feeds = self.getAllFeeds() return self.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): return calculateExpireDate(self.preferences()) # # handling of the selected feed entry # def selectFeedEntry(self, index): self.selectedFeedEntry = self.feedEntries[index] self._markSelectedFeedEntryRead() return self.selectedFeedEntry