Skip to content

Commit

Permalink
#3 Removendo valores magicos
Browse files Browse the repository at this point in the history
  • Loading branch information
hpe95 committed Jun 8, 2018
1 parent 7c8eccf commit 5c82e7d
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions radar_parlamentar/importadores/sen.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@
VOTACOES_FOLDER = os.path.join(DATA_FOLDER, 'votacoes')

NOME_CURTO = 'sen'
NOME_EXTENSO = 'Senado'
PARTIDO_PT = 13
SEM_PARTIDO = 0
STATUS_SUCESSO = 200

XML_FILE = 'dados/chefe_executivo/chefe_executivo_congresso.xml.bz2'

Expand All @@ -59,7 +63,7 @@ def gera_senado(self):

if not models.CasaLegislativa.objects.filter(nome_curto=NOME_CURTO):
sen = models.CasaLegislativa()
sen.nome = 'Senado'
sen.nome = NOME_EXTENSO
sen.nome_curto = NOME_CURTO
sen.esfera = models.FEDERAL
sen.save()
Expand Down Expand Up @@ -339,7 +343,7 @@ def importar_votacoes(self):
for xml_url in list_xml:
try:
response = requests.get(xml_url)
if response.status_code == 200:
if response.status_code == STATUS_SUCESSO:
xml_text = response.text
logger.debug('Importando %s' % xml_url)
self._save_votacoes_in_db(xml_text)
Expand All @@ -359,11 +363,11 @@ def consertar_suplicy_sem_partido(self):
try:
suplicy_sem_partido = models.Parlamentar.objects.get(
nome='Eduardo Suplicy',
partido__numero=0,
partido__numero=SEM_PARTIDO,
casa_legislativa__nome_curto='sen')
suplicy_do_pt = models.Parlamentar.objects.get(
nome='Eduardo Suplicy',
partido__numero=13,
partido__numero=PARTIDO_PT,
casa_legislativa__nome_curto='sen')
votos = models.Voto.objects.filter(parlamentar=suplicy_sem_partido)
for v in votos:
Expand Down

0 comments on commit 5c82e7d

Please sign in to comment.