+ # -- Create 'empty' contacts with birthdays...
+ #
+ if self.create_empty:
+ for name in self.friends:
+ friend = self.friends[name]
+ if 'contact' in friend or 'birthday_date' not in friend or not friend['birthday_date']:
+ continue
+
+ contact = evolution.ebook.EContact()
+ contact.props.full_name = friend['name']
+ contact.props.given_name = friend['first_name']
+ contact.props.family_name = friend['last_name']
+
+ self.update_contact(contact, friend)
+
+ addresses.add_contact(contact)
+ self.updated.append(contact)
+ addresses.commit_contact(contact)
+
+ print "Created [%s]" % (contact.get_name())
+ self.matched.append(contact)
+
+ self.store.close()
+
+
+ # -----------------------------------------------------------------------
+ def update_contact(self, contact, friend, resync = False):
+ """Update the given contact with information from the 'friend'
+ dictionary."""
+
+ updated = False
+ friend['contact'] = contact
+
+ if 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):
+ date_str = friend['birthday_date'].split('/')
+ date_str.append('0')
+ updated = self.store.set_birthday(contact, int(date_str[1]),
+ int(date_str[0]),
+ int(date_str[2])) or updated
+
+ if 'profile_url' in friend and friend['profile_url']:
+ updated = self.store.add_url(contact, friend['profile_url'], unique='facebook.com') or updated
+
+ if 'twitter_url' in friend and friend['twitter_url']:
+ updated = self.store.add_url(contact, friend['twitter_url'], unique='twitter.com') or updated
+
+ if 'homepage' in friend and friend['homepage']:
+ updated = self.store.add_url(contact, friend['homepage']) or updated
+
+ return updated