Try to tolerate Facebook violating their own API (i.e. by not
[hermes] / package / src / hermes.py
index e844113..76329ef 100644 (file)
@@ -127,13 +127,18 @@ class Hermes:
       for friend in self.fb.users.getInfo(self.fb.friends.get(), attrs):
         key = unicode(friend['name']).encode('trans')
         self.friends[key] = friend
+
+        if 'profile_url' not in friend:
+          friend['profile_url'] = "http://www.facebook.com/profile.php?id=" + str(friend ['uid'])
+
         self.friends_by_url[friend['profile_url']] = friend
         friend['pic']  = friend[attrs[2]]
         friend['account'] = 'facebook'
-        if friend['website']:
+
+        if 'website' in friend and friend['website']:
           friend['homepage'] = friend['website']
 
-        if not friend['pic']:
+        if 'pic' not in friend or not friend['pic']:
           self.blocked_pictures.append(friend)
           
           
@@ -245,10 +250,10 @@ class Hermes:
     updated = False
     friend['contact'] = contact
       
-    if friend['pic'] and (resync or contact.get_property('photo') is None):
+    if 'pic' in friend and friend['pic'] and (resync or contact.get_property('photo') is None):
       updated = self.store.set_photo(contact, friend['pic']) or updated
         
-    if friend['birthday_date'] and (resync or contact.get_property('birth-date') is None):
+    if 'birthday_date' in friend and friend['birthday_date'] and (resync or contact.get_property('birth-date') is None):
       date_str = friend['birthday_date'].split('/')
       date_str.append('0')
       updated = self.store.set_birthday(contact, int(date_str[1]),