changeset 11:428d45a1ef44

dealt with case in which whoisi doesn't include deleted folks
author Atul Varma <varmaa@toolness.com>
date Thu, 31 Dec 2009 18:19:14 -0800
parents b6259e713533
children eb6569ee2c48
files whoisi_cache.py
diffstat 1 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/whoisi_cache.py	Thu Dec 31 15:56:39 2009 -0800
+++ b/whoisi_cache.py	Thu Dec 31 18:19:14 2009 -0800
@@ -1,6 +1,7 @@
 import logging
 import urllib
 import urllib2
+from copy import deepcopy
 
 try:
     import json
@@ -9,6 +10,9 @@
 
 MAX_PEOPLE_REQ_SIZE = 100
 DEFAULT_URL = "http://whoisi.com/"
+EMPTY_PERSON = {'aliases': [],
+                'sites': {},
+                'name': ''}
 
 def split_seq(seq, size):
     """
@@ -69,4 +73,8 @@
                                             first=first,
                                             last=last)
             for person_id in range(first, last + 1):
-                self.people.append(result['people'][str(person_id)])
+                if str(person_id) in result['people']:
+                    person = result['people'][str(person_id)]
+                else:
+                    person = deepcopy(EMPTY_PERSON)
+                self.people.append(person)