Skip to content

Commit 0dd57ce

Browse files
committed
temp
1 parent 304ddf8 commit 0dd57ce

30 files changed

+6745
-5
lines changed

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
.PHONY : docs
2+
docs :
3+
rm -rf docs/build/
4+
sphinx-autobuild -b html --watch brazilcep/ docs/source/ docs/build/
5+
16
.PHONY : run-checks
27
run-checks :
38
isort --check .

brazilcep/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
:license: MIT, see LICENSE for more details.
1313
"""
1414

15+
from .version import VERSION, VERSION_SHORT
1516
from .client import WebService, get_address_from_cep
1617

1718
__all__ = [

brazilcep/py.typed

Whitespace-only changes.

brazilcep/version.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
_MAJOR = "6"
2+
_MINOR = "3"
3+
# On main and in a nightly release the patch should be one ahead of the last
4+
# released build.
5+
_PATCH = "1"
6+
# This is mainly for nightly builds which have the suffix ".dev$DATE". See
7+
# https://semver.org/#is-v123-a-semantic-version for the semantics.
8+
_SUFFIX = ""
9+
10+
VERSION_SHORT = "{0}.{1}".format(_MAJOR, _MINOR)
11+
VERSION = "{0}.{1}.{2}{3}".format(_MAJOR, _MINOR, _PATCH, _SUFFIX)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

docs/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
build

docs/Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line, and also
5+
# from the environment for the first two.
6+
SPHINXOPTS ?= -W
7+
SPHINXBUILD ?= sphinx-build
8+
SOURCEDIR = source
9+
BUILDDIR = build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

docs/make.bat

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
@ECHO OFF
2+
3+
pushd %~dp0
4+
5+
REM Command file for Sphinx documentation
6+
7+
if "%SPHINXBUILD%" == "" (
8+
set SPHINXBUILD=sphinx-build
9+
)
10+
set SOURCEDIR=source
11+
set BUILDDIR=build
12+
13+
if "%1" == "" goto help
14+
15+
%SPHINXBUILD% >NUL 2>NUL
16+
if errorlevel 9009 (
17+
echo.
18+
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
19+
echo.installed, then set the SPHINXBUILD environment variable to point
20+
echo.to the full path of the 'sphinx-build' executable. Alternatively you
21+
echo.may add the Sphinx directory to PATH.
22+
echo.
23+
echo.If you don't have Sphinx installed, grab it from
24+
echo.https://www.sphinx-doc.org/
25+
exit /b 1
26+
)
27+
28+
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
29+
goto end
30+
31+
:help
32+
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
33+
34+
:end
35+
popd

docs/source/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CHANGELOG.md

docs/source/CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CONTRIBUTING.md

docs/source/_static/favicon.ico

14.7 KB
Binary file not shown.

docs/source/_static/logo.png

20.2 KB
Loading

docs/source/_templates/hacks.html

Lines changed: 1820 additions & 0 deletions
Large diffs are not rendered by default.

docs/source/_templates/sidebarintro.html

Lines changed: 2576 additions & 0 deletions
Large diffs are not rendered by default.

docs/source/_templates/sidebarlogo.html

Lines changed: 1820 additions & 0 deletions
Large diffs are not rendered by default.

docs/source/conf.py

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
# Configuration file for the Sphinx documentation builder.
2+
#
3+
# This file only contains a selection of the most common options. For a full
4+
# list see the documentation:
5+
# https://www.sphinx-doc.org/en/master/usage/configuration.html
6+
7+
import logging
8+
import os
9+
import sys
10+
from datetime import datetime
11+
12+
# -- Path setup --------------------------------------------------------------
13+
14+
# If extensions (or modules to document with autodoc) are in another directory,
15+
# add these directories to sys.path here. If the directory is relative to the
16+
# documentation root, use os.path.abspath to make it absolute, like shown here.
17+
#
18+
19+
sys.path.insert(0, os.path.abspath("../../"))
20+
21+
from brazilcep import VERSION, VERSION_SHORT # noqa: E402
22+
23+
# -- Project information -----------------------------------------------------
24+
25+
project = "brazilcep"
26+
copyright = f"{datetime.today().year}, Michell Stuttgart"
27+
author = "Michell Stuttgart"
28+
version = VERSION_SHORT
29+
release = VERSION
30+
31+
32+
# -- General configuration ---------------------------------------------------
33+
34+
# Add any Sphinx extension module names here, as strings. They can be
35+
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
36+
# ones.
37+
extensions = [
38+
"sphinx.ext.autodoc",
39+
"sphinx.ext.napoleon",
40+
"myst_parser",
41+
"sphinx.ext.intersphinx",
42+
"sphinx.ext.viewcode",
43+
"sphinx.ext.doctest",
44+
"sphinx_copybutton",
45+
"sphinx_autodoc_typehints",
46+
]
47+
48+
# Tell myst-parser to assign header anchors for h1-h3.
49+
myst_heading_anchors = 3
50+
51+
suppress_warnings = ["myst.header"]
52+
53+
# Add any paths that contain templates here, relative to this directory.
54+
templates_path = ["_templates"]
55+
56+
# List of patterns, relative to source directory, that match files and
57+
# directories to ignore when looking for source files.
58+
# This pattern also affects html_static_path and html_extra_path.
59+
exclude_patterns = ["_build"]
60+
61+
source_suffix = [".rst", ".md"]
62+
63+
intersphinx_mapping = {
64+
"python": ("https://docs.python.org/3", None),
65+
# Uncomment these if you use them in your codebase:
66+
# "torch": ("https://pytorch.org/docs/stable", None),
67+
# "datasets": ("https://huggingface.co/docs/datasets/master/en", None),
68+
# "transformers": ("https://huggingface.co/docs/transformers/master/en", None),
69+
}
70+
71+
# By default, sort documented members by type within classes and modules.
72+
autodoc_member_order = "groupwise"
73+
74+
# Include default values when documenting parameter types.
75+
typehints_defaults = "comma"
76+
77+
78+
# -- Options for HTML output -------------------------------------------------
79+
80+
# The theme to use for HTML and HTML Help pages. See the documentation for
81+
# a list of builtin themes.
82+
#
83+
html_theme = "alabaster"
84+
85+
html_title = f"brazilcep v{VERSION}"
86+
87+
# Add any paths that contain custom static files (such as style sheets) here,
88+
# relative to this directory. They are copied after the builtin static files,
89+
# so a file named "default.css" will overwrite the builtin "default.css".
90+
html_static_path = ["_static"]
91+
92+
# html_css_files = ["css/custom.css"]
93+
94+
html_favicon = "_static/favicon.ico"
95+
96+
html_theme_options = {
97+
"logo": "logo.png",
98+
"show_powered_by": False,
99+
"github_user": "mstuttgart",
100+
"github_repo": "brazilcep",
101+
"github_banner": True,
102+
"show_related": False,
103+
"note_bg": "#FFF59C",
104+
}
105+
106+
# Custom sidebar templates, maps document names to template names.
107+
html_sidebars = {
108+
"index": ["sidebarintro.html", "sourcelink.html", "searchbox.html", "hacks.html"],
109+
"**": [
110+
"sidebarlogo.html",
111+
"localtoc.html",
112+
"relations.html",
113+
"sourcelink.html",
114+
"searchbox.html",
115+
"hacks.html",
116+
],
117+
}
118+
119+
# -- Hack to get rid of stupid warnings from sphinx_autodoc_typehints --------
120+
121+
122+
class ShutupSphinxAutodocTypehintsFilter(logging.Filter):
123+
def filter(self, record: logging.LogRecord) -> bool:
124+
if "Cannot resolve forward reference" in record.msg:
125+
return False
126+
return True
127+
128+
129+
logging.getLogger("sphinx.sphinx_autodoc_typehints").addFilter(ShutupSphinxAutodocTypehintsFilter())

docs/source/index.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# **BrazilCEP**
2+
3+
```{toctree}
4+
:maxdepth: 2
5+
:hidden:
6+
:caption: Getting started
7+
8+
install
9+
tutorial
10+
migrate
11+
overview
12+
```
13+
14+
```{toctree}
15+
:hidden:
16+
:caption: Development
17+
18+
CHANGELOG
19+
CONTRIBUTING
20+
License <https://raw.githubusercontent.com/mstuttgart/brazilcep/main/LICENSE>
21+
GitHub Repository <https://github.com/mstuttgart/brazilcep>
22+
```
23+
24+
<!-- ## Indices and tables -->
25+
26+
<!-- ```{eval-rst} -->
27+
<!-- * :ref:`genindex` -->
28+
<!-- * :ref:`modindex` -->
29+
<!-- ``` -->
30+
<p align="center">
31+
32+
<a href="https://github.com/mstuttgart/brazilcep/actions?query=workflow%3A%22Github+CI%22">
33+
<img alt="GitHub Workflow Status" src="https://img.shields.io/github/actions/workflow/status/mstuttgart/brazilcep/test.yml?color=fcd800&branch=main">
34+
</a>
35+
36+
<a href="https://pypi.org/project/brazilcep">
37+
<img src="https://img.shields.io/pypi/v/brazilcep.svg?" alt="Ratings">
38+
</a>
39+
40+
<a href="https://pypi.org/project/brazilcep/">
41+
<img src="https://img.shields.io/pypi/pyversions/brazilcep.svg" alt="Version">
42+
</a>
43+
44+
</p>
45+
46+
47+
**BrazilCEP** is a minimalist and easy-to-use python library designed to query CEP (brazilian zip codes) data.
48+
49+
-----------------------------
50+
51+
Its objective is to provide a common query interface to all these search services, facilitating the integration of Python applications with these services.
52+
53+
```python
54+
>>> get_address_from_cep('37503-130')
55+
{
56+
'bairro': 'str',
57+
'cep': 'str',
58+
'cidade': 'str',
59+
'logradouro': 'str',
60+
'uf': 'str',
61+
'complemento': 'str',
62+
}
63+
```
64+
65+
**BrazilCEP** is the new name of former **PyCEPCorreio** python library. If you want to migrate the old code to the new version, please see the [migrate](/migrate) section.
66+
67+
## Features
68+
69+
* Cross-platform: Windows, Mac, and Linux are officially supported.
70+
* Works with Python 3.8, 3.9, 3.10, 3.11 and 3.12.
71+
* Currently supports several CEP API's:
72+
* [ViaCEP](https://viacep.com.br)
73+
* [ApiCEP (WideNet)](https://apicep.com)
74+
* [OpenCEP](https://opencep.com/)
75+
* [Correios (site)](https://www2.correios.com.br/sistemas/buscacep/resultadoBuscaEndereco.cfm)
76+
77+
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.
78+

docs/source/install.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Install
2+
3+
The recommended way to get BrazilCEP is to **install the latest stable release**
4+
via [pip](http://pip-installer.org>):
5+
6+
```sh
7+
pip install brazilcep
8+
```
9+
10+
We currently support **Python 3.8+ only**. Users on older interpreter versions
11+
are urged to upgrade.
12+
13+
BrazilCEP has only a few **direct dependencies**:
14+
15+
- [Zeep](https://pypi.org/project/zeep): for SOAP requests.
16+
- [requests](https://pypi.org/project/requests): for REST API requests.

docs/source/migrate.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Migrate
2+
3+
**BrazilCEP** is the new name of former **PycepCorreios**. This page
4+
guide you on to process of migrate old code to new version.
5+
6+
It's simples migrate te code and require minimal steps.
7+
8+
## imports
9+
10+
First, rename the `import` statements from:
11+
12+
```python title="PyCEPCorreios"
13+
import pycepcorreios
14+
```
15+
to
16+
17+
```python title="BrazilCEP"
18+
import brazilcep
19+
```
20+
21+
## Query results
22+
23+
The next step, is adjust the *keys* of query returned by `get_address_from_cep` function.
24+
25+
The keys have simply been translated to english. Take a look on this old code:
26+
27+
``` python title="PyCEPCorreios"
28+
>>> get_address_from_cep('37503-130')
29+
{
30+
'bairro': 'rua abc',
31+
'cep': '37503130',
32+
'cidade': 'city ABC',
33+
'logradouro': 'str',
34+
'uf': 'str',
35+
'complemento': 'str',
36+
}
37+
```
38+
This is the new code:
39+
40+
``` python title="BrazilCEP"
41+
>>> get_address_from_cep('37503-130')
42+
{
43+
'district': 'rua abc',
44+
'cep': '37503130',
45+
'city': 'city ABC',
46+
'street': 'str',
47+
'uf': 'str',
48+
'complement': 'str',
49+
}
50+
```
51+
52+
## Exceptions
53+
54+
The follow Exceptions have been removed.
55+
56+
```python
57+
exceptions.ConnectionError
58+
exceptions.Timeout
59+
exceptions.HTTPError
60+
exceptions.BaseException
61+
```
62+
63+
Please, use the [requests](https://requests.readthedocs.io/en/latest/user/quickstart/#errors-and-exceptions) exceptions instead.
64+
65+
## Questions?
66+
67+
The best way to send question is open a issue in **BrazilCEP** issue tracker [here](https://github.com/mstuttgart/brazilcep/issues).

0 commit comments

Comments
 (0)