def lookup(story_id, card_id, spider_name): try: story = get_story(story_id) card = get_card(story, card_id) spiders.lookup(story, card, spider_name) except Exception, e: log.exception(e)
def cards_update(story_id, card_id): story = get_story(story_id) card = obj_or_404(get_card(story, card_id)) data = dict(request.json) data.pop("evidences", None) data["_id"] = card["_id"] card = save_card(story, data) return cards_get(story_id, card_id)
def cards_update(story_id, card_id): story = get_story(story_id) card = obj_or_404(get_card(story, card_id)) data = dict(request.json) data.pop('evidences', None) data['_id'] = card['_id'] card = save_card(story, data) return cards_get(story_id, card_id)
def cards_get(story_id, card_id): story = get_story(story_id) card = get_card(story, card_id) card["evidences"] = get_evidences(card) return jsonify(card)
def cards_get(story_id, card_id): story = get_story(story_id) card = get_card(story, card_id) card['evidences'] = get_evidences(card) return jsonify(card)
'Wikipedia': Wikipedia } def lookup(story, card, spider_name): entity_type = card.get('type') spider_status = card.get('spider_status', {}) cls = SPIDERS.get(spider_name) if spider_status.get(spider_name) == 'done': return try: spider = cls() if entity_type == "Person": card = spider.search_person(story, card) elif entity_type == "Company": card = spider.search_company(story, card) elif entity_type == "Organization": card = spider.search_organization(story, card) else: card = spider.search_generic(story, card) except Exception, e: log.exception(e) ncard = get_card(story, unicode(card['_id'])) spider_status = ncard.get('spider_status', {}) spider_status[spider_name] = 'done' card['spider_status'] = spider_status save_card(story, card, lookup=False)