From d7e2a02733f7f7ab7f00711b0ac88c81951450b1 Mon Sep 17 00:00:00 2001 From: Romain Bignon Date: Sat, 24 Jul 2010 12:07:31 +0200 Subject: [PATCH] new class ContactPhoto which contains url and data for fullsize and thumbnail --- weboob/capabilities/contact.py | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/weboob/capabilities/contact.py b/weboob/capabilities/contact.py index 2418166b..3db053a6 100644 --- a/weboob/capabilities/contact.py +++ b/weboob/capabilities/contact.py @@ -17,6 +17,7 @@ from .cap import ICap +from weboob.tools.ordereddict import OrderedDict __all__ = ['ICapContact', 'Contact'] @@ -32,6 +33,20 @@ class ProfileNode(object): self.sufix = sufix self.flags = flags +class ContactPhoto(object): + def __init__(self, name): + self.name = name + self.url = u'' + self.data = '' + self.thumbnail_url = u'' + self.thumbnail_data = u'' + + def __iscomplete__(self): + return (self.data and (not self.thumbnail_url or self.thumbnail_data)) + + def __repr__(self): + return u'' % (self.name, len(self.data), len(self.thumbnail_data)) + class Contact(object): STATUS_ONLINE = 0x001 STATUS_AWAY = 0x002 @@ -45,9 +60,17 @@ class Contact(object): self.status_msg = u'' self.summary = u'' self.avatar = None - self.photos = [] + self.photos = OrderedDict() self.profile = None + def set_photo(self, name, **kwargs): + if not name in self.photos: + self.photos[name] = ContactPhoto(name) + + photo = self.photos[name] + for key, value in kwargs.iteritems(): + setattr(photo, key, value) + def iter_fields(self): return {'id': self.id, 'name': self.name,