Skip to content

Commit

Permalink
Remove CORREIOS API site support
Browse files Browse the repository at this point in the history
CORREIOS add captcha to CEP site.
  • Loading branch information
mstuttgart committed Sep 5, 2024
1 parent 6f03ab1 commit d4d6d87
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 119 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ Currently supports several CEP API's:
- [ViaCEP](https://viacep.com.br)
- [ApiCEP (WideNet)](https://apicep.com)
- [OpenCEP](https://opencep.com/)
- [Correios (site)](https://www2.correios.com.br/sistemas/buscacep/resultadoBuscaEndereco.cfm)

> [!NOTE]
> **BrazilCEP** is the new name of former **PyCEPCorreio** python library.
Expand Down
13 changes: 8 additions & 5 deletions brazilcep/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@

import enum
import re
from warnings import warn

from . import apicep, correios, opencep, viacep
from . import apicep, opencep, viacep

NUMBERS = re.compile(r"[^0-9]")
DEFAULT_TIMEOUT = 5 # in seconds
Expand All @@ -32,7 +33,8 @@ class WebService(enum.Enum):


services = {
WebService.CORREIOS: correios.fetch_address,
# TOFIX: compatibility adjust. remove CORREIOS in next version
WebService.CORREIOS: opencep.fetch_address,
WebService.VIACEP: viacep.fetch_address,
WebService.APICEP: apicep.fetch_address,
WebService.OPENCEP: opencep.fetch_address,
Expand All @@ -59,11 +61,12 @@ def get_address_from_cep(cep, webservice=WebService.APICEP, timeout=None, proxie
"""

if webservice == WebService.CORREIOS:
warn("CORREIOS is going to be deprecated. Please, use other webservice.", DeprecationWarning, stacklevel=2)

if webservice not in (value for _, value in WebService.__dict__.items()):
raise KeyError(
"""Invalid webservice. Please use this options:
WebService.VIACEP, WebService.APICEP, WebService.CORREIOs or WebService.OPENCEP
"""
"""Invalid webservice. Please use this options: WebService.VIACEP, WebService.APICEP or WebService.OPENCEP"""
)

kwargs = {}
Expand Down
91 changes: 0 additions & 91 deletions brazilcep/correios.py

This file was deleted.

1 change: 0 additions & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,5 @@ Its objective is to provide a common query interface to all these search service
* [ViaCEP](https://viacep.com.br)
* [ApiCEP (WideNet)](https://apicep.com)
* [OpenCEP](https://opencep.com/)
* [Correios (site)](https://www2.correios.com.br/sistemas/buscacep/resultadoBuscaEndereco.cfm)

BrazilCEP started as a personal study project and evolved into a serious and open source project that is used by many developers on a daily basis.
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ classifiers = [
"Natural Language :: Portuguese (Brazilian)",
]

dependencies = ["zeep>=4.2.1", "requests>=2.28.2", "beautifulsoup4>=4.12.3"]
dependencies = ["zeep>=4.2.1", "requests>=2.28.2"]

[project.optional-dependencies]

Expand All @@ -41,6 +41,7 @@ dev = [
"black>=23.0,<24.0",
"isort>=5.12,<5.13",
"ruff",
"ipdb",
]

coverage = ["coveralls>=3.3.1", "pytest-cov>=4.0.0", "requests-mock>=1.10.0"]
Expand Down
2 changes: 1 addition & 1 deletion tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import pytest

from brazilcep import get_address_from_cep, WebService
from brazilcep import WebService, get_address_from_cep
from brazilcep.client import _format_cep


Expand Down
19 changes: 0 additions & 19 deletions tests/test_correios.py

This file was deleted.

0 comments on commit d4d6d87

Please sign in to comment.