comparison 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
comparison
equal deleted inserted replaced
196:a9ba3e3a9a9a 197:e604c32f67aa
44 self._normalize(entry) 44 self._normalize(entry)
45 self._processEntry(entry) 45 self._processEntry(entry)
46 self._incrementFeedUpdateDate() 46 self._incrementFeedUpdateDate()
47 47
48 def _normalize(self, entry): 48 def _normalize(self, entry):
49 self._normalizeId(entry)
50 self._normalizePublishedDate(entry)
51 self._normalizeUpdatedDate(entry)
52 self._normalizeSummary(entry)
53
54 def _normalizeId(self, entry):
49 if not hasattr(entry, "id"): 55 if not hasattr(entry, "id"):
50 entry.id = entry.link 56 entry.id = entry.link
57
58 def _normalizePublishedDate(self, entry):
59 if not hasattr(entry, "published"):
60 if hasattr(entry, "updated"):
61 entry.published = entry.updated
62
63 def _normalizeUpdatedDate(self, entry):
51 if not hasattr(entry, "updated_parsed") or entry.updated_parsed is None: 64 if not hasattr(entry, "updated_parsed") or entry.updated_parsed is None:
52 # TODO try to parse the entry.updated date string 65 # TODO try to parse the entry.updated date string
53 entry.updated_parsed = datetime.today() 66 entry.updated_parsed = datetime.today()
54 else: 67 else:
55 entry.updated_parsed = datetime(*entry.updated_parsed[:6]) 68 entry.updated_parsed = datetime(*entry.updated_parsed[:6])
69
70 def _normalizeSummary(self, entry):
56 if not hasattr(entry, "summary"): 71 if not hasattr(entry, "summary"):
57 if hasattr(entry, "content"): 72 if hasattr(entry, "content"):
58 entry.summary = entry.content[0].value 73 entry.summary = entry.content[0].value
59 else: 74 else:
60 entry.summary = "" 75 entry.summary = ""