A package that helps you to get brazilian's offset codes.
Project description
PyCodigosBancos
PyCodigosBancos is a small Python library for working with Brazilian bank codes (lista de bancos). It provides a lightweight API to build an in-memory dictionary of banks and lookup helpers.
Installation
Install from PyPI (when published):
pip install -U PyCodigosBancos
Or install from source for development:
pip install -e .
Usage
Primary entrypoint: CodigosBancos (in py_codigos_bancos.codigos_bancos). The class builds a dictionary of Banco objects (by fetching and parsing codigobanco.com) and exposes lookup helpers. Example:
from py_codigos_bancos.codigos_bancos import CodigosBancos
cb = CodigosBancos()
# get all banks (list of dicts)
all_bancos = cb.get_bancos()
print(all_bancos[:2])
# lookup by code -> dict
b = cb.get_bancos_by_codigo(1)
print(b) # {'nome': 'Banco do Brasil', 'site': 'https://bb.example', 'codigo': 1}
# search by name (case-insensitive) -> list of dicts
matches = cb.get_bancos_by_nome('Banco do Brasil')
print(matches)
Notes:
- Methods return serializable dictionaries with keys:
nome,site,codigo. - Network access occurs when
CodigosBancos()is constructed; patch or mock_CodigosBancos__build_bancoin tests to avoid live requests.
API Reference
CodigosBancos
Key methods:
get_bancos() -> List[Dict]— returns all banks as a list of dicts[{"nome","site","codigo"}, ...].get_bancos_by_codigo(codigo: int) -> Dict— returns the bank dict forcodigo. RaisesValueErrorfor invalid or missing codes.get_bancos_by_nome(nome_banco: str) -> List[Dict]— case-insensitive substring search returning matching bank dicts. RaisesValueErrorif no matches.
Banco model (py_codigos_bancos.banco.Banco)
Simple data holder with attributes: codigo, nome, site.
Testing
Run the test suite with pytest:
pytest -q
Unit tests in tests/ patch the internal builder to avoid network calls.
Contributing
Contributions welcome. Open an issue to discuss major changes and keep tests updated.
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pycodigosbancos-0.0.2.tar.gz.
File metadata
- Download URL: pycodigosbancos-0.0.2.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
577c8bd238add8bba59df94e7a43b71bf69013e4b72e4cefa1e8e1003cc4a54b
|
|
| MD5 |
29146b6f6e28efa2c894e357db6afa60
|
|
| BLAKE2b-256 |
2f602fd8182d3dc08b682d5259a3e1a4d7f72188a047c2c7bdb9bd61badafee5
|
File details
Details for the file pycodigosbancos-0.0.2-py3-none-any.whl.
File metadata
- Download URL: pycodigosbancos-0.0.2-py3-none-any.whl
- Upload date:
- Size: 5.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
163718736e192ec41247b255acf81a7f3645ffd25cfe5ddadf266ed5f3b2a227
|
|
| MD5 |
2df16dcddba41170b3b064bc5fe36d05
|
|
| BLAKE2b-256 |
d4b8b5a0d0a746200b061d053ad7fa3f445acce1b73644c2e213c0cd415fd0b5
|