support signatures

This commit is contained in:
Romain Bignon 2011-03-16 13:50:12 +01:00
commit c9252a855b
3 changed files with 17 additions and 2 deletions

View file

@ -130,7 +130,8 @@ class DLFPBackend(BaseBackend, ICapMessages, ICapMessagesPost):
date=com.date, date=com.date,
parent=parent, parent=parent,
content=com.body, content=com.body,
signature='<br />'.join(['Score: %d' % com.score, signature=com.signature + \
'<br />'.join(['Score: %d' % com.score,
'URL: %s' % com.url]), 'URL: %s' % com.url]),
children=[], children=[],
flags=flags) flags=flags)

View file

@ -65,6 +65,7 @@ class DLFP(BaseBrowser):
self.location(url) self.location(url)
assert self.is_on_page(ContentPage) assert self.is_on_page(ContentPage)
self.page.url = self.absurl(url)
content = self.page.get_article() content = self.page.get_article()
content.id = _id content.id = _id
return content return content
@ -121,6 +122,7 @@ class DLFP(BaseBrowser):
self.location(url) self.location(url)
comment = None comment = None
self.page.url = self.absurl(url)
if self.is_on_page(CommentPage): if self.is_on_page(CommentPage):
comment = self.page.get_comment() comment = self.page.get_comment()
elif self.is_on_page(ContentPage): elif self.is_on_page(ContentPage):

View file

@ -34,6 +34,7 @@ class Comment(object):
self.username = None self.username = None
self.date = None self.date = None
self.body = u'' self.body = u''
self.signature = u''
self.score = 0 self.score = 0
self.url = u'' self.url = u''
self.comments = [] self.comments = []
@ -52,7 +53,18 @@ class Comment(object):
self.date = datetime.strptime(select(div.find('p'), 'time', 1).attrib['datetime'].split('+')[0], self.date = datetime.strptime(select(div.find('p'), 'time', 1).attrib['datetime'].split('+')[0],
'%Y-%m-%dT%H:%M:%S') '%Y-%m-%dT%H:%M:%S')
self.date = local2utc(self.date) self.date = local2utc(self.date)
self.body = self.browser.parser.tostring(div.find('div'))
content = div.find('div')
try:
signature = select(content, 'p.signature', 1)
except SelectElementException:
# No signature.
pass
else:
content.remove(signature)
self.signature = self.browser.parser.tostring(signature)
self.body = self.browser.parser.tostring(content)
self.score = int(select(div.find('p'), 'span.score', 1).text) self.score = int(select(div.find('p'), 'span.score', 1).text)
forms = select(div.find('footer'), 'form.button_to') forms = select(div.find('footer'), 'form.button_to')
if len(forms) == 0: if len(forms) == 0: