def _get_deputy_analysis(url, deputy, type, reset=False): soupsoup = read_or_dl(LACHAMBRE_PREFIX + lame_url(url), '%s %s' % (deputy.full_name, type), reset) setattr(deputy, "analysis_%s_url" % type, url) setattr(deputy, "analysis_%s_list" % type, []) for i in soupsoup('table')[3]('tr', valign="top"): logger.debug("add", type, i.tr('td')[1].text.strip()) dico = table2dic(i.table('td')) logger.debug("%s" % dico) getattr(deputy, "analysis_%s_list" % type).\ append(get_or_create(Analysis, _id="lachambre_id", lachambre_id=re.search("dossierID=([0-9A-Za-z-]+)", i.a["href"]).groups()[0], title=dico["Titre"], descriptor=dico["Descripteurs"], url=i.a['href'], type=type))
def _get_deputy_questions(url, deputy, type, reset=False): soupsoup = read_or_dl(LACHAMBRE_PREFIX + lame_url(url), '%s %s' % (deputy.full_name, type), reset) setattr(deputy, "questions_%s_url" % type, url) setattr(deputy, "questions_%s_list" % type, []) for i in soupsoup('table')[3]('tr', valign="top"): logger.debug("add", type, i.tr('td')[1].text.strip()) dico = table2dic(i.table('td')) logger.debug("%s" % dico) getattr(deputy, "questions_%s_list" % type).\ append(get_or_create(Question, _id="lachambre_id", title=dico["Titre"], lachambre_id=re.search("dossierID=([0-9A-Za-z-]+)", i.a["href"]).groups()[0], reunion_type=dico.get(u"Réunion"), reunion_date=dico.get("Date discussion"), session_id=dico.get("Session"), pdf_url=dico.get(u"Compte rendu intégral", {"href": None})["href"], eurovoc_descriptors=map(lambda x: x.strip(), dico.get("Descripteurs Eurovoc", "").split('|')), keywords=map(lambda x: x.strip(), dico.get(u"Mots-clés libres", "").split("|")), url=i.a['href'], type=type))