[aum] ICapMessages.iter_[new_]messages() implemented
This commit is contained in:
parent
76c4622dc3
commit
f3a017cb01
8 changed files with 63 additions and 90 deletions
|
|
@ -21,6 +21,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
from weboob.backend import Backend
|
||||
from weboob.capabilities.messages import ICapMessages, ICapMessagesReply
|
||||
|
||||
from .adopte import AdopteUnMec
|
||||
|
||||
class AuMBackend(Backend, ICapMessages, ICapMessagesReply):
|
||||
NAME = 'aum'
|
||||
MAINTAINER = 'Romain Bignon'
|
||||
|
|
@ -28,9 +30,45 @@ class AuMBackend(Backend, ICapMessages, ICapMessagesReply):
|
|||
VERSION = '1.0'
|
||||
LICENSE = 'GPLv3'
|
||||
DESCRIPTION = "French dating website"
|
||||
CONFIG = {'username': Backend.ConfigField(description='Username on website'),
|
||||
'password': Backend.ConfigField(description='Password of account', is_masked=True),
|
||||
}
|
||||
_browser = None
|
||||
|
||||
def __getattr__(self, name):
|
||||
if name == 'browser':
|
||||
if not self._browser:
|
||||
self._browser = AdopteUnMec(self.config['username'], self.config['password'])
|
||||
return self._browser
|
||||
raise AttributeError, name
|
||||
|
||||
def iter_messages(self, thread=None):
|
||||
return dict().iteritems()
|
||||
for message in self._iter_messages(thread, False):
|
||||
yield message
|
||||
|
||||
def iter_new_messages(self, thread=None):
|
||||
return dict().iteritems()
|
||||
for message in self._iter_messages(thread, True):
|
||||
yield message
|
||||
|
||||
def _iter_messages(self, thread, only_new):
|
||||
if not only_new or self.browser.nb_new_mails():
|
||||
my_name = self.browser.get_my_name()
|
||||
contacts = self.browser.get_contact_list()
|
||||
contacts.reverse()
|
||||
|
||||
for contact in contacts:
|
||||
if only_new and not contact.is_new():
|
||||
continue
|
||||
|
||||
mails = self.browser.get_thread_mails(contact.get_id())
|
||||
profile = None
|
||||
for i in xrange(len(mails)):
|
||||
mail = mails[i]
|
||||
if only_new and mail.get_from() == my_name:
|
||||
break
|
||||
|
||||
if not profile:
|
||||
profile = self.browser.get_profile(contact.get_id())
|
||||
mail.signature += u'\n%s' % profile.get_profile_text()
|
||||
print mail.signature
|
||||
yield mail
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue