Author: jtauber
Date: Thu Sep 25 03:07:21 2008
New Revision: 50
Modified:
trunk/friendsdev/friends/importer.py
Log:
yahoo import no longer crashes on missing first or last name
Modified: trunk/friendsdev/friends/importer.py
==============================================================================
--- trunk/friendsdev/friends/importer.py (original)
+++ trunk/friendsdev/friends/importer.py Thu Sep 25 03:07:21 2008
@@ -50,12 +50,28 @@
for contact in address_book["contacts"]:
total += 1
email = contact['fields'][0]['data']
- name = contact['fields'][1]['first'] + contact['fields'][1]['last']
+ try:
+ first_name = contact['fields'][1]['first']
+ except (KeyError, IndexError):
+ first_name = None
+ try:
+ last_name = contact['fields'][1]['last']
+ except (KeyError, IndexError):
+ last_name = None
+ if first_name and last_name:
+ name = first_name + " " + last_name
+ elif first_name:
+ name = first_name
+ elif last_name:
+ name = last_name
+ else:
+ name = None
try:
Contact.objects.get(user=user, email=email)
except Contact.DoesNotExist:
Contact(user=user, name=name, email=email).save()
imported += 1
+
return imported, total
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pinax-updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/pinax-updates?hl=en
-~----------~----~----~----~------~----~------~--~---