-
-
Notifications
You must be signed in to change notification settings - Fork 61
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
feat:retorna codigo do ibge do nome do municipio e da uf #411
base: main
Are you sure you want to change the base?
Changes from all commits
3fe9e01
ca5973a
9030c34
19ced13
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -88,6 +88,7 @@ False | |||||||
- [format_voter_id](#format_voter_id) | ||||||||
- [generate_voter_id](#generate_voter_id) | ||||||||
- [IBGE](#ibge) | ||||||||
- [get_code_by_municipality_name](#get_code_by_municipality_name) | ||||||||
- [convert_code_to_uf](#convert_code_to_uf) | ||||||||
|
||||||||
## CPF | ||||||||
|
@@ -1110,6 +1111,35 @@ Exemplo: | |||||||
``` | ||||||||
|
||||||||
|
||||||||
### get_code_by_municipality_name | ||||||||
|
||||||||
Retorna o código IBGE para um dado nome de município e código de UF. | ||||||||
|
||||||||
Essa função recebe uma string representando o nome de um município e o código da UF, e retorna o código IBGE correspondente (string). A função lida com os nomes ignorando diferenças de maiúsculas, acentos, tratando o caractere "ç" como "c", e ignorando diferenças de maiúsculas para o código da UF. | ||||||||
|
||||||||
Argumentos: | ||||||||
* municipality_name (str): O nome do município. | ||||||||
* uf (str): O código UF do estado. | ||||||||
|
||||||||
Retorna: | ||||||||
* str: O código IBGE do município. Retorna None se o nome não for válido ou não existir. | ||||||||
Exemplo: | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Boa @mateusoliveira43 ! Vou adicionar a sugestão aqui:
Suggested change
|
||||||||
|
||||||||
``` | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. python There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
>>> from brutils import get_code_by_municipality_name | ||||||||
>>> get_code_by_municipality_name("São Paulo", "SP") | ||||||||
"3550308" | ||||||||
>>> get_code_by_municipality_name("goiania", "go") | ||||||||
"5208707" | ||||||||
>>> get_code_by_municipality_name("Conceição do Coité", "BA") | ||||||||
"2908408" | ||||||||
>>> get_code_by_municipality_name("conceicao do Coite", "Ba") | ||||||||
"2908408" | ||||||||
>>> get_code_by_municipality_name("Municipio Inexistente", "") | ||||||||
None | ||||||||
>>> get_code_by_municipality_name("Municipio Inexistente", "RS") | ||||||||
None | ||||||||
``` | ||||||||
# Novos Utilitários e Reportar Bugs | ||||||||
|
||||||||
Caso queira sugerir novas funcionalidades ou reportar bugs, basta criar | ||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,6 +88,7 @@ False | |
- [format_voter_id](#format_voter_id) | ||
- [generate_voter_id](#generate_voter_id) | ||
- [IBGE](#ibge) | ||
- [get_code_by_municipality_name](#get_code_by_municipality_name) | ||
- [convert_code_to_uf](#convert_code_to_uf) | ||
|
||
## CPF | ||
|
@@ -1090,6 +1091,7 @@ Example: | |
``` | ||
|
||
## IBGE | ||
|
||
### convert_code_to_uf | ||
Converts a given IBGE code (2-digit string) to its corresponding UF (state abbreviation). | ||
|
||
|
@@ -1110,6 +1112,41 @@ Exemplo: | |
'RJ' | ||
>>> convert_code_to_uf("99") | ||
>>> | ||
>>>>>>> main | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. essa modificação está correta? |
||
``` | ||
|
||
### get_code_by_municipality_name | ||
|
||
Returns the IBGE code for a given municipality name and uf code. | ||
|
||
This function takes a string representing a municipality's name | ||
and uf's code and returns the corresponding IBGE code (string). The function | ||
will handle names by ignoring differences in case, accents, and | ||
treating the character ç as c and ignoring case differences for the uf code. | ||
|
||
Args: | ||
* municipality_name (str): The name of the municipality. | ||
* uf (str): The uf code of the state. | ||
|
||
Returns: | ||
* str: The IBGE code of the municipality. Returns None if the name is not valid or does not exist. | ||
|
||
Example: | ||
|
||
```python | ||
>>> from brutils import get_code_by_municipality_name | ||
>>> get_code_by_municipality_name("São Paulo", "SP") | ||
"3550308" | ||
>>> get_code_by_municipality_name("goiania", "go") | ||
"5208707" | ||
>>> get_code_by_municipality_name("Conceição do Coité", "BA") | ||
"2908408" | ||
>>> get_code_by_municipality_name("conceicao do Coite", "Ba") | ||
"2908408" | ||
>>> get_code_by_municipality_name("Municipio Inexistente", "") | ||
None | ||
>>> get_code_by_municipality_name("Municipio Inexistente", "RS") | ||
None | ||
``` | ||
|
||
# Feature Request and Bug Report | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pular linha aqui por conta da formatação