Mercurial > hg > Feedworm
diff backend/AbstractFeedUpdater.py @ 197:e604c32f67aa
normalize the published date if the feed contains none
author | dirk |
---|---|
date | Tue, 24 Jan 2012 10:08:45 +0100 |
parents | 2f2016a10f7d |
children | f74fe7cb5091 |
line wrap: on
line diff
--- a/backend/AbstractFeedUpdater.py Tue Jan 24 08:25:29 2012 +0100 +++ b/backend/AbstractFeedUpdater.py Tue Jan 24 10:08:45 2012 +0100 @@ -46,13 +46,28 @@ self._incrementFeedUpdateDate() def _normalize(self, entry): + self._normalizeId(entry) + self._normalizePublishedDate(entry) + self._normalizeUpdatedDate(entry) + self._normalizeSummary(entry) + + def _normalizeId(self, entry): if not hasattr(entry, "id"): entry.id = entry.link + + def _normalizePublishedDate(self, entry): + if not hasattr(entry, "published"): + if hasattr(entry, "updated"): + entry.published = entry.updated + + def _normalizeUpdatedDate(self, entry): if not hasattr(entry, "updated_parsed") or entry.updated_parsed is None: # TODO try to parse the entry.updated date string entry.updated_parsed = datetime.today() else: entry.updated_parsed = datetime(*entry.updated_parsed[:6]) + + def _normalizeSummary(self, entry): if not hasattr(entry, "summary"): if hasattr(entry, "content"): entry.summary = entry.content[0].value