Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Buscar código ibge com nome da cidade com e sem apóstrofo #122

Merged
merged 1 commit into from
Oct 29, 2021

Conversation

leogregianin
Copy link
Collaborator

Dependendo da base de dados utilizada os nomes das cidades são enviadas sem apóstrofo.
Ocorre o erro abaixo:

Python 3.7.3 (default, Jan 22 2021, 20:04:44) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> 
>>> from terceiros.PyNFe.pynfe.utils import *
>>> obter_codigo_por_municipio("Conquista D'Oeste", 'MT')
'5103361'
>>> obter_codigo_por_municipio("Conquista DOeste", 'MT')
Traceback (most recent call last):
  File "/usr/lib/python3.7/code.py", line 90, in runcode
    exec(code, self.locals)
  File "<console>", line 1, in <module>
  File "/home/leo/Documentos/lucrorural/backend/terceiros/PyNFe/pynfe/utils/__init__.py", line 98, in obter_codigo_por_municipio
    return municipios[normalizar_municipio(municipio)]
KeyError: 'CONQUISTA DOESTE'
>>> 

Após aplicar esse PR posso utilizar das duas formas como segue abaixo:

Python 3.7.3 (default, Jan 22 2021, 20:04:44) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> 
>>> from terceiros.PyNFe.pynfe.utils import *
>>> obter_codigo_por_municipio("Conquista D'Oeste", 'MT')
'5103361'
>>> obter_codigo_por_municipio("Conquista DOeste", 'MT')
'5103361'
>>> 

@juniortada juniortada merged commit 95a128d into TadaSoftware:master Oct 29, 2021
@leogregianin leogregianin deleted the fix/busca_ibge_cidade branch January 26, 2022 04:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants