python-bcb 0.4.1__tar.gz → 0.4.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {python_bcb-0.4.1 → python_bcb-0.4.2}/CHANGELOG.md +8 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/PKG-INFO +22 -2
- {python_bcb-0.4.1 → python_bcb-0.4.2}/README.md +1 -1
- {python_bcb-0.4.1 → python_bcb-0.4.2}/bcb/odata/api.py +34 -3
- {python_bcb-0.4.1 → python_bcb-0.4.2}/docs/odata.rst +27 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/pyproject.toml +40 -1
- {python_bcb-0.4.1 → python_bcb-0.4.2}/tests/test_odata.py +71 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/uv.lock +1 -1
- {python_bcb-0.4.1 → python_bcb-0.4.2}/.claude/plans/dynamic-bubbling-glade.md +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/.claude/plans/phase2-review.md +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/.claude/plans/phase4-review.md +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/.claude/plans/recursive-sniffing-snowflake.md +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/.claude/plans/text-output.md +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/.claude/settings.json +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/.claude/settings.local.json +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/.github/workflows/dependency-audit.yml +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/.github/workflows/integration.yml +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/.github/workflows/lint.yml +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/.github/workflows/sphinx.yml +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/.github/workflows/test.yml +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/.gitignore +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/.python-version +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/CLAUDE.md +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/LICENSE +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/QUESTIONS.md +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/bcb/__init__.py +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/bcb/currency.py +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/bcb/exceptions.py +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/bcb/http.py +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/bcb/odata/__init__.py +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/bcb/odata/framework.py +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/bcb/sgs/__init__.py +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/bcb/sgs/regional_economy.py +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/bcb/utils.py +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/docs/.claude/settings.local.json +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/docs/Makefile +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/docs/_static/images/ipca12m-acumulado.png +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/docs/_static/images/savefig/currency1.png +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/docs/_static/images/savefig/ifdata_credito_comparativo.png +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/docs/_static/images/savefig/ifdata_credito_evolucao.png +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/docs/_static/images/savefig/sgs1.png +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/docs/_static/images/savefig/taxajuros1.png +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/docs/_static/images/selic.png +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/docs/api.rst +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/docs/async.rst +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/docs/conf.py +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/docs/currency.rst +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/docs/expectativas.rst +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/docs/ifdata.rst +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/docs/index.rst +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/docs/make.bat +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/docs/project-health-hardening.md +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/docs/sgs.rst +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/docs/taxajuros.rst +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/examples/async_usage.py +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/examples/currency_exchange.py +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/examples/odata_query.py +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/examples/sgs_time_series.py +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/notebooks/SGS Economia Regional - Inadimpl/303/252ncia.ipynb" +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/notebooks/bcb_Expectativas_da_SELIC_(nova_API).ipynb +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/notebooks/currency PTAX.ipynb +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/notebooks/currency get EUR parity.ipynb +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/notebooks/currency get strong currencies.ipynb +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/notebooks/currency get with side.ipynb +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/notebooks/currency get.ipynb +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/notebooks/dinheiro em circula/303/247/303/243o.ipynb" +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/notebooks/expectativas IPCA anual.ipynb +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/notebooks/odata ODataAPI.ipynb +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/notebooks/odata examples.ipynb +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/notebooks/odata taxas de juros cheque especial.ipynb +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/notebooks/pix.odata +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/notebooks/sgs get series with join.ipynb +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/notebooks/sgs get series with period index.ipynb +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/notebooks/sgs get series.ipynb +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/notebooks/workspace.ipynb +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/tests/__init__.py +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/tests/conftest.py +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/tests/integration/__init__.py +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/tests/integration/test_currency.py +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/tests/integration/test_expectativas.py +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/tests/integration/test_sgs.py +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/tests/sgs/__init__.py +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/tests/sgs/test_regional_economy.py +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/tests/sgs/test_series.py +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/tests/test_async.py +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/tests/test_currency.py +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/tests/test_currency_negative.py +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/tests/test_exceptions.py +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/tests/test_expectativas.py +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/tests/test_http.py +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/tests/test_request_timeout.py +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/tests/test_sgs_negative.py +0 -0
- {python_bcb-0.4.1 → python_bcb-0.4.2}/tests/test_utils.py +0 -0
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.4.2] - 2026-11-22
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
- `BaseODataAPI` and `ODataAPI` accept a `parameter_formatters` argument, so `ODataAPI(url)` users can set how function import parameters are formatted without writing a subclass. Instance formatters are merged on top of the class `PARAMETER_FORMATTERS`: `PTAX()` keeps its date formatters, and callers can add to or override them for one instance only. Thanks @jackiectl2. (#70, #74)
|
|
7
|
+
|
|
8
|
+
### Changed
|
|
9
|
+
- Improved the PyPI project page: added license metadata (`MIT`), keywords, classifiers and project links (documentation, repository, issues, changelog), and made the README examples link absolute so it works on PyPI. (#67)
|
|
10
|
+
|
|
3
11
|
## [0.4.1] - 2026-10-23
|
|
4
12
|
|
|
5
13
|
### Fixed
|
|
@@ -1,9 +1,29 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: python-bcb
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.2
|
|
4
4
|
Summary: Interface Python para APIs de dados abertos do Banco Central do Brasil.
|
|
5
|
+
Project-URL: Homepage, https://github.com/wilsonfreitas/python-bcb
|
|
6
|
+
Project-URL: Documentation, https://wilsonfreitas.github.io/python-bcb/
|
|
7
|
+
Project-URL: Repository, https://github.com/wilsonfreitas/python-bcb
|
|
8
|
+
Project-URL: Issues, https://github.com/wilsonfreitas/python-bcb/issues
|
|
9
|
+
Project-URL: Changelog, https://github.com/wilsonfreitas/python-bcb/blob/main/CHANGELOG.md
|
|
5
10
|
Author-email: wilsonfreitas <wilson.freitas@gmail.com>
|
|
11
|
+
License-Expression: MIT
|
|
6
12
|
License-File: LICENSE
|
|
13
|
+
Keywords: banco central do brasil,bcb,dados abertos,economics,expectativas,finance,focus,ifdata,odata,open data,ptax,sgs,time series
|
|
14
|
+
Classifier: Development Status :: 4 - Beta
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Intended Audience :: Financial and Insurance Industry
|
|
17
|
+
Classifier: Intended Audience :: Science/Research
|
|
18
|
+
Classifier: Natural Language :: Portuguese (Brazilian)
|
|
19
|
+
Classifier: Operating System :: OS Independent
|
|
20
|
+
Classifier: Programming Language :: Python :: 3
|
|
21
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
25
|
+
Classifier: Topic :: Office/Business :: Financial
|
|
26
|
+
Classifier: Topic :: Scientific/Engineering :: Information Analysis
|
|
7
27
|
Requires-Python: >=3.10
|
|
8
28
|
Requires-Dist: httpx>=0.24.0
|
|
9
29
|
Requires-Dist: lxml>=4.9.2
|
|
@@ -221,6 +241,6 @@ A saída HTML é gerada em `docs/_build/html`. Edite os arquivos fonte em `docs/
|
|
|
221
241
|
### P: Onde encontro documentação mais detalhada?
|
|
222
242
|
**R:**
|
|
223
243
|
- [Documentação de API](https://wilsonfreitas.github.io/python-bcb/)
|
|
224
|
-
- [Diretório de Exemplos](
|
|
244
|
+
- [Diretório de Exemplos](https://github.com/wilsonfreitas/python-bcb/tree/main/examples)
|
|
225
245
|
- Docstrings inline: `help(bcb.sgs.get)`, `help(bcb.currency.get)`, etc.
|
|
226
246
|
- [Portal de Dados Abertos BCB](https://dadosabertos.bcb.gov.br/)
|
|
@@ -208,6 +208,6 @@ A saída HTML é gerada em `docs/_build/html`. Edite os arquivos fonte em `docs/
|
|
|
208
208
|
### P: Onde encontro documentação mais detalhada?
|
|
209
209
|
**R:**
|
|
210
210
|
- [Documentação de API](https://wilsonfreitas.github.io/python-bcb/)
|
|
211
|
-
- [Diretório de Exemplos](
|
|
211
|
+
- [Diretório de Exemplos](https://github.com/wilsonfreitas/python-bcb/tree/main/examples)
|
|
212
212
|
- Docstrings inline: `help(bcb.sgs.get)`, `help(bcb.currency.get)`, etc.
|
|
213
213
|
- [Portal de Dados Abertos BCB](https://dadosabertos.bcb.gov.br/)
|
|
@@ -409,11 +409,27 @@ class BaseODataAPI:
|
|
|
409
409
|
DATE_COLUMNS: list[str] = []
|
|
410
410
|
PARAMETER_FORMATTERS: dict[str, Callable[[Any], Any]] = {}
|
|
411
411
|
|
|
412
|
-
def __init__(
|
|
412
|
+
def __init__(
|
|
413
|
+
self,
|
|
414
|
+
*,
|
|
415
|
+
timeout: RequestTimeout = None,
|
|
416
|
+
parameter_formatters: Optional[dict[str, Callable[[Any], Any]]] = None,
|
|
417
|
+
) -> None:
|
|
413
418
|
"""
|
|
414
419
|
BaseODataAPI construtor
|
|
420
|
+
|
|
421
|
+
Parameters
|
|
422
|
+
----------
|
|
423
|
+
|
|
424
|
+
parameter_formatters : dict[str, Callable], optional
|
|
425
|
+
Formatadores de parâmetros dos *function imports*, indexados pelo
|
|
426
|
+
nome do parâmetro. Cada função recebe o valor informado e retorna
|
|
427
|
+
o valor usado no literal OData. Esses formatadores são aplicados
|
|
428
|
+
sobre os definidos em ``PARAMETER_FORMATTERS``, podendo
|
|
429
|
+
complementá-los ou substituí-los.
|
|
415
430
|
"""
|
|
416
431
|
self._timeout = timeout
|
|
432
|
+
self._parameter_formatters = dict(parameter_formatters or {})
|
|
417
433
|
self.service = ODataService(self.BASE_URL, timeout=timeout)
|
|
418
434
|
|
|
419
435
|
def describe(self, endpoint: Optional[str] = None, *, full: bool = True) -> None:
|
|
@@ -463,11 +479,15 @@ class BaseODataAPI:
|
|
|
463
479
|
ValueError
|
|
464
480
|
Se o *endpoint* fornecido é errado.
|
|
465
481
|
"""
|
|
482
|
+
parameter_formatters = {
|
|
483
|
+
**self.PARAMETER_FORMATTERS,
|
|
484
|
+
**self._parameter_formatters,
|
|
485
|
+
}
|
|
466
486
|
return Endpoint(
|
|
467
487
|
self.service[endpoint],
|
|
468
488
|
self.service.url,
|
|
469
489
|
self.DATE_COLUMNS or None,
|
|
470
|
-
|
|
490
|
+
parameter_formatters or None,
|
|
471
491
|
timeout=self._timeout,
|
|
472
492
|
)
|
|
473
493
|
|
|
@@ -483,7 +503,13 @@ class ODataAPI(BaseODataAPI):
|
|
|
483
503
|
não possuem implementação específica.
|
|
484
504
|
"""
|
|
485
505
|
|
|
486
|
-
def __init__(
|
|
506
|
+
def __init__(
|
|
507
|
+
self,
|
|
508
|
+
url: str,
|
|
509
|
+
*,
|
|
510
|
+
timeout: RequestTimeout = None,
|
|
511
|
+
parameter_formatters: Optional[dict[str, Callable[[Any], Any]]] = None,
|
|
512
|
+
) -> None:
|
|
487
513
|
"""
|
|
488
514
|
Parameters
|
|
489
515
|
----------
|
|
@@ -499,8 +525,13 @@ class ODataAPI(BaseODataAPI):
|
|
|
499
525
|
|
|
500
526
|
- Expectativas
|
|
501
527
|
- PTAX
|
|
528
|
+
parameter_formatters : dict[str, Callable], optional
|
|
529
|
+
Formatadores de parâmetros dos *function imports*, indexados pelo
|
|
530
|
+
nome do parâmetro. Cada função recebe o valor informado e retorna
|
|
531
|
+
o valor usado no literal OData.
|
|
502
532
|
"""
|
|
503
533
|
self._timeout = timeout
|
|
534
|
+
self._parameter_formatters = dict(parameter_formatters or {})
|
|
504
535
|
self.service = ODataService(url, timeout=timeout)
|
|
505
536
|
|
|
506
537
|
|
|
@@ -481,3 +481,30 @@ Essa API pode ser diretamente acessada através da classe :py:class:`bcb.odata.a
|
|
|
481
481
|
service = ODataAPI(url)
|
|
482
482
|
service.describe()
|
|
483
483
|
|
|
484
|
+
Formatando parâmetros
|
|
485
|
+
^^^^^^^^^^^^^^^^^^^^^
|
|
486
|
+
|
|
487
|
+
Alguns *function imports* esperam parâmetros em um formato específico, por
|
|
488
|
+
exemplo datas como ``AAAAMM``. O argumento ``parameter_formatters`` associa o
|
|
489
|
+
nome de um parâmetro a uma função, que recebe o valor informado na consulta e
|
|
490
|
+
retorna o valor usado no literal OData. As aspas dos parâmetros ``Edm.String``
|
|
491
|
+
continuam sendo adicionadas pela biblioteca depois da formatação.
|
|
492
|
+
|
|
493
|
+
.. code:: python
|
|
494
|
+
|
|
495
|
+
import pandas as pd
|
|
496
|
+
from bcb import ODataAPI
|
|
497
|
+
|
|
498
|
+
url = "https://olinda.bcb.gov.br/olinda/servico/IFDATA/versao/v1/odata/"
|
|
499
|
+
api = ODataAPI(
|
|
500
|
+
url,
|
|
501
|
+
parameter_formatters={"AnoMes": lambda v: v.strftime("%Y%m")},
|
|
502
|
+
)
|
|
503
|
+
ep = api.get_endpoint("IfDataCadastro")
|
|
504
|
+
ep.get(AnoMes=pd.Timestamp("2024-03-01"), limit=10)
|
|
505
|
+
|
|
506
|
+
O mesmo argumento é aceito pelas classes específicas, como
|
|
507
|
+
:py:class:`bcb.odata.api.PTAX`. Os formatadores informados são combinados com
|
|
508
|
+
os definidos na classe (``PARAMETER_FORMATTERS``): é possível adicionar
|
|
509
|
+
formatadores para outros parâmetros ou substituir os padrões sem criar uma
|
|
510
|
+
subclasse e sem afetar outras instâncias.
|
|
@@ -1,10 +1,42 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "python-bcb"
|
|
3
|
-
version = "0.4.
|
|
3
|
+
version = "0.4.2"
|
|
4
4
|
description = "Interface Python para APIs de dados abertos do Banco Central do Brasil."
|
|
5
5
|
authors = [{ name = "wilsonfreitas", email = "wilson.freitas@gmail.com" }]
|
|
6
6
|
readme = "README.md"
|
|
7
|
+
license = "MIT"
|
|
8
|
+
license-files = ["LICENSE"]
|
|
7
9
|
requires-python = ">= 3.10"
|
|
10
|
+
keywords = [
|
|
11
|
+
"banco central do brasil",
|
|
12
|
+
"bcb",
|
|
13
|
+
"dados abertos",
|
|
14
|
+
"open data",
|
|
15
|
+
"sgs",
|
|
16
|
+
"odata",
|
|
17
|
+
"ptax",
|
|
18
|
+
"focus",
|
|
19
|
+
"expectativas",
|
|
20
|
+
"ifdata",
|
|
21
|
+
"finance",
|
|
22
|
+
"economics",
|
|
23
|
+
"time series",
|
|
24
|
+
]
|
|
25
|
+
classifiers = [
|
|
26
|
+
"Development Status :: 4 - Beta",
|
|
27
|
+
"Intended Audience :: Developers",
|
|
28
|
+
"Intended Audience :: Financial and Insurance Industry",
|
|
29
|
+
"Intended Audience :: Science/Research",
|
|
30
|
+
"Natural Language :: Portuguese (Brazilian)",
|
|
31
|
+
"Operating System :: OS Independent",
|
|
32
|
+
"Programming Language :: Python :: 3",
|
|
33
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
34
|
+
"Programming Language :: Python :: 3.10",
|
|
35
|
+
"Programming Language :: Python :: 3.11",
|
|
36
|
+
"Programming Language :: Python :: 3.12",
|
|
37
|
+
"Topic :: Office/Business :: Financial",
|
|
38
|
+
"Topic :: Scientific/Engineering :: Information Analysis",
|
|
39
|
+
]
|
|
8
40
|
dependencies = [
|
|
9
41
|
"httpx >= 0.24.0",
|
|
10
42
|
"lxml >= 4.9.2",
|
|
@@ -12,6 +44,13 @@ dependencies = [
|
|
|
12
44
|
"tenacity >= 8.0.0",
|
|
13
45
|
]
|
|
14
46
|
|
|
47
|
+
[project.urls]
|
|
48
|
+
Homepage = "https://github.com/wilsonfreitas/python-bcb"
|
|
49
|
+
Documentation = "https://wilsonfreitas.github.io/python-bcb/"
|
|
50
|
+
Repository = "https://github.com/wilsonfreitas/python-bcb"
|
|
51
|
+
Issues = "https://github.com/wilsonfreitas/python-bcb/issues"
|
|
52
|
+
Changelog = "https://github.com/wilsonfreitas/python-bcb/blob/main/CHANGELOG.md"
|
|
53
|
+
|
|
15
54
|
[dependency-groups]
|
|
16
55
|
test = [
|
|
17
56
|
"pytest >= 7.1.3",
|
|
@@ -796,6 +796,77 @@ def test_ptax_parameters_keep_existing_ptax_date_strings(httpx_mock):
|
|
|
796
796
|
assert request.url.params["@dataFinalCotacao"] == "'01-05-2022'"
|
|
797
797
|
|
|
798
798
|
|
|
799
|
+
def test_odata_api_parameter_formatters_apply_to_that_instance_only(httpx_mock):
|
|
800
|
+
httpx_mock.add_response(
|
|
801
|
+
url=FUNCTION_BASE_URL, text=FUNCTION_SERVICE_ROOT_JSON, is_reusable=True
|
|
802
|
+
)
|
|
803
|
+
httpx_mock.add_response(url=FUNCTION_METADATA_URL, content=FUNCTION_METADATA_XML)
|
|
804
|
+
httpx_mock.add_response(
|
|
805
|
+
url=FUNCTION_URL_PATTERN, text=ODATA_QUERY_RESPONSE_JSON, is_reusable=True
|
|
806
|
+
)
|
|
807
|
+
formatters = {"dataInicial": lambda value: value.strftime("%m-%d-%Y")}
|
|
808
|
+
|
|
809
|
+
formatted = ODataAPI(FUNCTION_BASE_URL, parameter_formatters=formatters)
|
|
810
|
+
plain = ODataAPI(FUNCTION_BASE_URL)
|
|
811
|
+
for api in (formatted, plain):
|
|
812
|
+
api.get_endpoint("CotacaoMoedaPeriodo").get(
|
|
813
|
+
moeda="USD",
|
|
814
|
+
dataInicial=pd.Timestamp("2022-01-31"),
|
|
815
|
+
limite=5,
|
|
816
|
+
output="text",
|
|
817
|
+
)
|
|
818
|
+
|
|
819
|
+
formatted_request, plain_request = [
|
|
820
|
+
request
|
|
821
|
+
for request in httpx_mock.get_requests()
|
|
822
|
+
if "CotacaoMoedaPeriodo" in request.url.path
|
|
823
|
+
]
|
|
824
|
+
assert formatted_request.url.params["@dataInicial"] == "'01-31-2022'"
|
|
825
|
+
assert formatted_request.url.params["@moeda"] == "'USD'"
|
|
826
|
+
assert formatted_request.url.params["@limite"] == "5"
|
|
827
|
+
assert plain_request.url.params["@dataInicial"] == "'2022-01-31 00:00:00'"
|
|
828
|
+
assert ODataAPI.PARAMETER_FORMATTERS == {}
|
|
829
|
+
|
|
830
|
+
|
|
831
|
+
def test_ptax_parameter_formatters_extend_and_override_class_defaults(httpx_mock):
|
|
832
|
+
httpx_mock.add_response(
|
|
833
|
+
url=PTAX_BASE_URL, text=PTAX_SERVICE_ROOT_JSON, is_reusable=True
|
|
834
|
+
)
|
|
835
|
+
httpx_mock.add_response(url=PTAX_METADATA_URL, content=PTAX_METADATA_XML)
|
|
836
|
+
httpx_mock.add_response(
|
|
837
|
+
url=PTAX_PERIODO_URL_PATTERN, text=ODATA_QUERY_RESPONSE_JSON, is_reusable=True
|
|
838
|
+
)
|
|
839
|
+
class_formatters = dict(PTAX.PARAMETER_FORMATTERS)
|
|
840
|
+
formatters = {
|
|
841
|
+
"moeda": str.upper,
|
|
842
|
+
"dataFinalCotacao": lambda value: value.strftime("%d/%m/%Y"),
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
custom = PTAX(parameter_formatters=formatters)
|
|
846
|
+
default = PTAX()
|
|
847
|
+
for api in (custom, default):
|
|
848
|
+
api.get_endpoint("CotacaoMoedaPeriodo").get(
|
|
849
|
+
moeda="usd",
|
|
850
|
+
dataInicial="2022-01-01",
|
|
851
|
+
dataFinalCotacao=date(2022, 1, 5),
|
|
852
|
+
output="text",
|
|
853
|
+
)
|
|
854
|
+
|
|
855
|
+
custom_request, default_request = [
|
|
856
|
+
request
|
|
857
|
+
for request in httpx_mock.get_requests()
|
|
858
|
+
if "CotacaoMoedaPeriodo" in request.url.path
|
|
859
|
+
]
|
|
860
|
+
assert custom_request.url.params["@moeda"] == "'USD'"
|
|
861
|
+
assert custom_request.url.params["@dataInicial"] == "'01-01-2022'"
|
|
862
|
+
assert custom_request.url.params["@dataFinalCotacao"] == "'05/01/2022'"
|
|
863
|
+
assert default_request.url.params["@moeda"] == "'usd'"
|
|
864
|
+
assert default_request.url.params["@dataInicial"] == "'01-01-2022'"
|
|
865
|
+
assert default_request.url.params["@dataFinalCotacao"] == "'01-05-2022'"
|
|
866
|
+
assert PTAX.PARAMETER_FORMATTERS == class_formatters
|
|
867
|
+
assert list(formatters) == ["moeda", "dataFinalCotacao"]
|
|
868
|
+
|
|
869
|
+
|
|
799
870
|
# ---------------------------------------------------------------------------
|
|
800
871
|
# DATE_COLUMNS — configurable date detection (Phase 7.1)
|
|
801
872
|
# ---------------------------------------------------------------------------
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_bcb-0.4.1 → python_bcb-0.4.2}/docs/_static/images/savefig/ifdata_credito_comparativo.png
RENAMED
|
File without changes
|
{python_bcb-0.4.1 → python_bcb-0.4.2}/docs/_static/images/savefig/ifdata_credito_evolucao.png
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_bcb-0.4.1 → python_bcb-0.4.2}/notebooks/SGS Economia Regional - Inadimpl/303/252ncia.ipynb"
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|