correctly set when a message is new
This commit is contained in:
parent
dcfae72688
commit
64f0b50d13
3 changed files with 49 additions and 59 deletions
|
|
@ -1,22 +1,19 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
"""
|
# Copyright(C) 2008-2010 Romain Bignon
|
||||||
Copyright(C) 2008-2010 Romain Bignon
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify
|
||||||
This program is free software; you can redistribute it and/or modify
|
# it under the terms of the GNU General Public License as published by
|
||||||
it under the terms of the GNU General Public License as published by
|
# the Free Software Foundation, version 3 of the License.
|
||||||
the Free Software Foundation, version 3 of the License.
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
This program is distributed in the hope that it will be useful,
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# GNU General Public License for more details.
|
||||||
GNU General Public License for more details.
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
You should have received a copy of the GNU General Public License
|
# along with this program; if not, write to the Free Software
|
||||||
along with this program; if not, write to the Free Software
|
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
|
|
||||||
"""
|
|
||||||
|
|
||||||
import re
|
import re
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
@ -159,7 +156,7 @@ class MailParser(Message):
|
||||||
self.id = self.get_date_int()
|
self.id = self.get_date_int()
|
||||||
|
|
||||||
if m.group(7).find('nouveau') >= 0:
|
if m.group(7).find('nouveau') >= 0:
|
||||||
self.new = True
|
self.is_new = True
|
||||||
else:
|
else:
|
||||||
error('Error: unable to parse the datetime string "%s"' % date_str)
|
error('Error: unable to parse the datetime string "%s"' % date_str)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,19 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
"""
|
# Copyright(C) 2010 Romain Bignon
|
||||||
Copyright(C) 2010 Romain Bignon
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify
|
||||||
This program is free software; you can redistribute it and/or modify
|
# it under the terms of the GNU General Public License as published by
|
||||||
it under the terms of the GNU General Public License as published by
|
# the Free Software Foundation, version 3 of the License.
|
||||||
the Free Software Foundation, version 3 of the License.
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
This program is distributed in the hope that it will be useful,
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# GNU General Public License for more details.
|
||||||
GNU General Public License for more details.
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
You should have received a copy of the GNU General Public License
|
# along with this program; if not, write to the Free Software
|
||||||
along with this program; if not, write to the Free Software
|
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
|
|
||||||
"""
|
|
||||||
|
|
||||||
from weboob.backend import BaseBackend
|
from weboob.backend import BaseBackend
|
||||||
from weboob.tools.browser import BrowserUnavailable
|
from weboob.tools.browser import BrowserUnavailable
|
||||||
|
|
@ -87,7 +84,8 @@ class DLFPBackend(BaseBackend, ICapMessages, ICapMessagesReply):
|
||||||
article.datetime,
|
article.datetime,
|
||||||
content=''.join([thread.body, thread.part2]),
|
content=''.join([thread.body, thread.part2]),
|
||||||
signature='URL: %s' % article.url,
|
signature='URL: %s' % article.url,
|
||||||
is_html=True)
|
is_html=True
|
||||||
|
is_new=new)
|
||||||
|
|
||||||
for comment in thread.iter_all_comments():
|
for comment in thread.iter_all_comments():
|
||||||
if not comment.id in seen[article.id]['comments']:
|
if not comment.id in seen[article.id]['comments']:
|
||||||
|
|
@ -104,7 +102,8 @@ class DLFPBackend(BaseBackend, ICapMessages, ICapMessagesReply):
|
||||||
comment.reply_id,
|
comment.reply_id,
|
||||||
comment.body,
|
comment.body,
|
||||||
'Score: %d' % comment.score,
|
'Score: %d' % comment.score,
|
||||||
is_html=True)
|
is_html=True,
|
||||||
|
is_new=new)
|
||||||
# If there is no articles seen, it's suspicious, probably I can't
|
# If there is no articles seen, it's suspicious, probably I can't
|
||||||
# fetch the feed.
|
# fetch the feed.
|
||||||
if seen:
|
if seen:
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,19 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
"""
|
# Copyright(C) 2010 Romain Bignon
|
||||||
Copyright(C) 2010 Romain Bignon
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify
|
||||||
This program is free software; you can redistribute it and/or modify
|
# it under the terms of the GNU General Public License as published by
|
||||||
it under the terms of the GNU General Public License as published by
|
# the Free Software Foundation, version 3 of the License.
|
||||||
the Free Software Foundation, version 3 of the License.
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
This program is distributed in the hope that it will be useful,
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# GNU General Public License for more details.
|
||||||
GNU General Public License for more details.
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
You should have received a copy of the GNU General Public License
|
# along with this program; if not, write to the Free Software
|
||||||
along with this program; if not, write to the Free Software
|
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
|
|
||||||
"""
|
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
import time
|
import time
|
||||||
|
|
@ -24,7 +21,7 @@ import time
|
||||||
from .cap import ICap
|
from .cap import ICap
|
||||||
|
|
||||||
class Message:
|
class Message:
|
||||||
def __init__(self, thread_id, _id, title, sender, date=None, reply_id=u'', content=u'', signature=u'', is_html=False):
|
def __init__(self, thread_id, _id, title, sender, date=None, reply_id=u'', content=u'', signature=u'', is_html=False, is_new=False):
|
||||||
self.thread_id = unicode(thread_id)
|
self.thread_id = unicode(thread_id)
|
||||||
self.id = unicode(_id)
|
self.id = unicode(_id)
|
||||||
self.reply_id = unicode(reply_id)
|
self.reply_id = unicode(reply_id)
|
||||||
|
|
@ -32,11 +29,11 @@ class Message:
|
||||||
self.sender = unicode(sender)
|
self.sender = unicode(sender)
|
||||||
self.signature = unicode(signature)
|
self.signature = unicode(signature)
|
||||||
|
|
||||||
self.new = False
|
|
||||||
self.content = content
|
self.content = content
|
||||||
if date is None:
|
if date is None:
|
||||||
date = datetime.datetime.utcnow()
|
date = datetime.datetime.utcnow()
|
||||||
self.date = date
|
self.date = date
|
||||||
|
self.is_new = is_new
|
||||||
self.is_html = is_html
|
self.is_html = is_html
|
||||||
|
|
||||||
def get_date_int(self):
|
def get_date_int(self):
|
||||||
|
|
@ -72,9 +69,6 @@ class Message:
|
||||||
def get_signature(self):
|
def get_signature(self):
|
||||||
return self.signature
|
return self.signature
|
||||||
|
|
||||||
def is_new(self):
|
|
||||||
return self.new
|
|
||||||
|
|
||||||
def __eq__(self, msg):
|
def __eq__(self, msg):
|
||||||
return self.id == msg.id and self.thread_id == msg.thread_id
|
return self.id == msg.id and self.thread_id == msg.thread_id
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue