def objectFromJSON(event): try: parse_event = Event() if isInvalidAttribute(event['event_name']): return parse_event.title = event['event_name'] if isInvalidAttribute(event['web_description']): return parse_event.description = event['web_description'] if isInvalidAttribute(str(event['event_id'])): return parse_event.eventId = str(event['event_id']) try: parse_event.location = GeoPoint(latitude=float(event['geocode_latitude']), longitude=float(event['geocode_longitude'])) except: print "Invalid lat/long" if isInvalidAttribute(event['street_address']): return parse_event.address = event['street_address'] if isInvalidAttribute(event['venue_name']): return parse_event.venueName = event['venue_name'] if isInvalidAttribute(event['date_time_description']): return parse_event.startTime = event['date_time_description'] parse_event.photoURL = DEFAULT_PHOTO if isInvalidAttribute(event['category']): return parse_event.category = event['category'] if isInvalidAttribute(event['event_detail_url']): return parse_event.eventURL = event['event_detail_url'] return parse_event except KeyError: print "We missed a key!"
def objectFromJSON(event, category): try: parse_event = Event() if isInvalidAttribute(event['title']): return parse_event.title = event['title'] if isInvalidAttribute(event['description']): return parse_event.description = event['description'] if isInvalidAttribute(event['id']): return parse_event.eventId = event['id'] try: parse_event.location = GeoPoint( latitude=float(event['latitude']), longitude=float(event['longitude'])) except: print "Invalid lat/long" if isInvalidAttribute(event['venue_address']): return parse_event.address = event['venue_address'] if isInvalidAttribute(event['venue_name']): return parse_event.venueName = event['venue_name'] if isInvalidAttribute(event['start_time']): return parse_event.startTime = event['start_time'] if not getPhotoURL(event): return parse_event.photoURL = getPhotoURL(event) if isInvalidAttribute(event['url']): print "We f****d this up." return parse_event.eventURL = event['url'] parse_event.category = category return parse_event except KeyError: print "We missed a key!"