From 6973611e2a3e9fd22efeec7c1e5078922397819a Mon Sep 17 00:00:00 2001 From: Romain Bignon Date: Tue, 28 Sep 2010 11:00:03 +0200 Subject: [PATCH] leto's bug: display a warning when it happens, and backend ignores malformated threads --- weboob/backends/aum/backend.py | 4 ++++ weboob/backends/aum/pages/contact_list.py | 8 +++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/weboob/backends/aum/backend.py b/weboob/backends/aum/backend.py index a64493ae..5e0bf32b 100644 --- a/weboob/backends/aum/backend.py +++ b/weboob/backends/aum/backend.py @@ -94,6 +94,8 @@ class AuMBackend(BaseBackend, ICapMessages, ICapMessagesPost, ICapDating, ICapCh contacts = self.browser.get_threads_list() for contact in contacts: + if not contact.get_id(): + continue thread = Thread(contact.get_id()) yield thread @@ -169,6 +171,8 @@ class AuMBackend(BaseBackend, ICapMessages, ICapMessagesPost, ICapDating, ICapCh with self.browser: contacts = self.browser.get_threads_list() for contact in contacts: + if not contact.get_id(): + continue slut = self._get_slut(contact.get_id()) if contact.get_lastmsg_date() > slut['lastmsg']: thread = self.get_thread(contact.get_id(), profiles) diff --git a/weboob/backends/aum/pages/contact_list.py b/weboob/backends/aum/pages/contact_list.py index f07b718e..9e889ead 100644 --- a/weboob/backends/aum/pages/contact_list.py +++ b/weboob/backends/aum/pages/contact_list.py @@ -49,6 +49,7 @@ class ContactItem: def __init__(self, tr): self.tr = tr + self.id = 0 def __get_element(self, id): return self.tr.getElementsByTagName('td')[self.fields.index(id)] @@ -107,6 +108,9 @@ class ContactItem: return None def get_id(self): + if self.id: + return self.id + tag = self.__get_element('thread_link') text = tag.getAttribute('onclick') @@ -115,8 +119,10 @@ class ContactItem: m = regexp.match(text) if m: - return int(m.group(1)) + self.id = int(m.group(1)) + return self.id + warning('Unable to parse ID (%s)' % text) return 0