From 64f0b50d130342fce55adefa862d0327bf161d6f Mon Sep 17 00:00:00 2001 From: Romain Bignon Date: Thu, 27 May 2010 14:34:47 +0200 Subject: [PATCH] correctly set when a message is new --- weboob/backends/aum/pages/contact_thread.py | 33 ++++++++---------- weboob/backends/dlfp/backend.py | 37 ++++++++++---------- weboob/capabilities/messages.py | 38 +++++++++------------ 3 files changed, 49 insertions(+), 59 deletions(-) diff --git a/weboob/backends/aum/pages/contact_thread.py b/weboob/backends/aum/pages/contact_thread.py index dfe69258..de29c3d2 100644 --- a/weboob/backends/aum/pages/contact_thread.py +++ b/weboob/backends/aum/pages/contact_thread.py @@ -1,22 +1,19 @@ # -*- coding: utf-8 -*- -""" -Copyright(C) 2008-2010 Romain Bignon - -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 -the Free Software Foundation, version 3 of the License. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -""" +# Copyright(C) 2008-2010 Romain Bignon +# +# 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 +# the Free Software Foundation, version 3 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. import re from datetime import datetime @@ -159,7 +156,7 @@ class MailParser(Message): self.id = self.get_date_int() if m.group(7).find('nouveau') >= 0: - self.new = True + self.is_new = True else: error('Error: unable to parse the datetime string "%s"' % date_str) diff --git a/weboob/backends/dlfp/backend.py b/weboob/backends/dlfp/backend.py index 0dce5fa4..bcc53183 100644 --- a/weboob/backends/dlfp/backend.py +++ b/weboob/backends/dlfp/backend.py @@ -1,22 +1,19 @@ # -*- coding: utf-8 -*- -""" -Copyright(C) 2010 Romain Bignon - -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 -the Free Software Foundation, version 3 of the License. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -""" +# Copyright(C) 2010 Romain Bignon +# +# 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 +# the Free Software Foundation, version 3 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. from weboob.backend import BaseBackend from weboob.tools.browser import BrowserUnavailable @@ -87,7 +84,8 @@ class DLFPBackend(BaseBackend, ICapMessages, ICapMessagesReply): article.datetime, content=''.join([thread.body, thread.part2]), signature='URL: %s' % article.url, - is_html=True) + is_html=True + is_new=new) for comment in thread.iter_all_comments(): if not comment.id in seen[article.id]['comments']: @@ -104,7 +102,8 @@ class DLFPBackend(BaseBackend, ICapMessages, ICapMessagesReply): comment.reply_id, comment.body, '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 # fetch the feed. if seen: diff --git a/weboob/capabilities/messages.py b/weboob/capabilities/messages.py index 8cba989d..bc03e2fa 100644 --- a/weboob/capabilities/messages.py +++ b/weboob/capabilities/messages.py @@ -1,22 +1,19 @@ # -*- coding: utf-8 -*- -""" -Copyright(C) 2010 Romain Bignon - -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 -the Free Software Foundation, version 3 of the License. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -""" +# Copyright(C) 2010 Romain Bignon +# +# 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 +# the Free Software Foundation, version 3 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. import datetime import time @@ -24,7 +21,7 @@ import time from .cap import ICap 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.id = unicode(_id) self.reply_id = unicode(reply_id) @@ -32,11 +29,11 @@ class Message: self.sender = unicode(sender) self.signature = unicode(signature) - self.new = False self.content = content if date is None: date = datetime.datetime.utcnow() self.date = date + self.is_new = is_new self.is_html = is_html def get_date_int(self): @@ -72,9 +69,6 @@ class Message: def get_signature(self): return self.signature - def is_new(self): - return self.new - def __eq__(self, msg): return self.id == msg.id and self.thread_id == msg.thread_id