[Hepserver-commits] messaging/messaging/formats rss.py,1.8,1.9
Status: Alpha
Brought to you by:
abefettig
|
From: <abe...@us...> - 2003-08-07 03:31:02
|
Update of /cvsroot/hepserver//messaging/messaging/formats
In directory sc8-pr-cvs1:/tmp/cvs-serv15557/messaging/formats
Modified Files:
rss.py
Log Message:
use new message API with dict-like interface
for headers (still in flux).
Index: rss.py
===================================================================
RCS file: /cvsroot/hepserver//messaging/messaging/formats/rss.py,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** rss.py 9 Jul 2003 16:15:24 -0000 1.8
--- rss.py 7 Aug 2003 03:30:57 -0000 1.9
***************
*** 1,5 ****
from messaging.message import Message
from messaging.formats import Parser
! from extlib import rssparser
import md5
import base64
--- 1,5 ----
from messaging.message import Message
from messaging.formats import Parser
! from extlib import feedparser
import md5
import base64
***************
*** 33,37 ****
headers = {}
! parser = rssparser.RSSParser()
parser.feed(rssDocument)
channel, items = parser.channel, parser.items
--- 33,37 ----
headers = {}
! parser = feedparser.FeedParser()
parser.feed(rssDocument)
channel, items = parser.channel, parser.items
***************
*** 43,49 ****
if item.has_key('title'):
! m.title = html2text(item['title'])
else:
! m.title = headers.get('title','')
if item.has_key('content_encoded'):
--- 43,49 ----
if item.has_key('title'):
! m['title'] = html2text(item['title'])
else:
! m['title'] = headers.get('title','')
if item.has_key('content_encoded'):
***************
*** 57,91 ****
if item.has_key('link'):
! m.link = item['link']
elif item.has_key('guid'):
if parser.guidislink:
! m.link = item['guid']
if item.has_key('guid'):
! m.guid = "<rss:%s>" % item['guid']
! else:
! # calculate the ID by hashing the title and body
! # FIXME: this should include link, and probably content:encoded if description
! # isn't there. also it should use messages.title instead of m.title.
! # Or it could not set the guid at all, and let the Message class generate
! # it automatically....
!
! hash = md5.new()
! if item.has_key('title'):
! hash.update(item['title'])
! if item.has_key('description'):
! hash.update(item['description'])
! m.guid = "<" + safeChars(hash.hexdigest() + "@" + m.title[:10]) + ">"
if item.has_key('date'):
! try: m.timestamp = item['date']
except: pass
elif channel.has_key('date'):
# fall back to the channel's modify date
! try: m.timestamp = channel['date']
except: pass
if channel.has_key('title'):
! m.author.name = channel['title']
messages.append(m)
--- 57,78 ----
if item.has_key('link'):
! m['link'] = item['link']
elif item.has_key('guid'):
if parser.guidislink:
! m['link'] = item['guid']
if item.has_key('guid'):
! m['Message-ID'] = "<rss:%s>" % item['guid']
if item.has_key('date'):
! try: m.setTimestamp(item['date'])
except: pass
elif channel.has_key('date'):
# fall back to the channel's modify date
! try: m.setTimestamp(channel['date'])
except: pass
if channel.has_key('title'):
! m['author'].name = channel['title']
messages.append(m)
|