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

feat:retorna codigo do ibge do nome do municipio e da uf #411

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Utilitário `convert_code_to_uf` [#397](https://github.com/brazilian-utils/brutils-python/pull/410)

- Utilitário `get_code_by_municipality_name` [#399](https://github.com/brazilian-utils/brutils-python/issues/399)

## [2.2.0] - 2024-09-12

### Added
Expand Down
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Boa @mateusoliveira43 ! Vou adicionar a sugestão aqui:

Suggested change
Exemplo:
Exemplo:


```

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

python

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
```
```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
```
# Novos Utilitários e Reportar Bugs

Caso queira sugerir novas funcionalidades ou reportar bugs, basta criar
Expand Down
37 changes: 37 additions & 0 deletions README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -1090,6 +1091,7 @@ Example:
```

## IBGE

### convert_code_to_uf
Converts a given IBGE code (2-digit string) to its corresponding UF (state abbreviation).

Expand All @@ -1110,6 +1112,41 @@ Exemplo:
'RJ'
>>> convert_code_to_uf("99")
>>>
>>>>>>> main

Choose a reason for hiding this comment

The 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
Expand Down
4 changes: 4 additions & 0 deletions brutils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
from brutils.email import is_valid as is_valid_email

# IBGE Imports
from brutils.ibge.municipality import (
get_code_by_municipality_name,
)
from brutils.ibge.uf import (
convert_code_to_uf,
)
Expand Down Expand Up @@ -172,4 +175,5 @@
"is_valid_voter_id",
# IBGE
"convert_code_to_uf",
"get_code_by_municipality_name",
]
Loading