Blake Carver wrote:
>
> The feeds I run usually have the date/time of an item in
> 'modified_parsed' (from "Universal Feed Parser"), but, according to the
> feed parser docs, dates can be in 'modified_parsed, or 'date_parsed', or
> 'created_parsed' depending on the type of feed.
> So essentially the item_date variable in the below code snippet could be
> any of those three items coming from the feed parser.
Right, sorry, i thought you were tweaking the feedparser itself...
haven't had coffee yet. :(
> So what I think should be happening in this little piece of code, is
> something like this:
>
> for item in entries
> item_date is equal to 'modified_parsed, or 'date_parsed', or 'created_parsed'
> if none of those, then just set it to now
This should work, though there's certainly a more concise way.
for item in entries:
for key in ('modified_parsed, 'date_parsed', 'created_parsed'):
if item.has_key(key):
item_date = item[key]
break
if not isinstance(time_date, time.struct_time):
time_date = time.localtime()
Now for that coffee...
-Dan
--
Daniel Chudnov
Yale Center for Medical Informatics
(203) 737-5789
|