- s = GetSites(a['site_ids'], ['name'])
- if len(s) > 0:
- organization = s[0]['name']
- else:
- organization = "Unknown"
- a['name'] = organization
- print "%(email)s,%(first_name)s %(last_name)s,%(name)s" % a
+ if 'site_ids' in a:
+ s = GetSites(a['site_ids'], ['name'])
+ if len(s) > 0:
+ organization = s[0]['name']
+ else:
+ organization = "Unknown"
+ else:
+ organization = "Unknown"
+
+ a['name'] = organization
+ print "%(email)s,%(first_name)s %(last_name)s,%(name)s" % a