From a9225be58683fefcc09cedd9c0b928d587a2085b Mon Sep 17 00:00:00 2001 From: Luis Rodrigues Date: Thu, 22 Aug 2024 21:33:40 +0100 Subject: [PATCH] =?UTF-8?q?[feature]=20#2:=20valida=C3=A7=C3=A3o=20chave?= =?UTF-8?q?=20API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit implementação da função 'aux.validarChaveAPI()' --- crypto_portfolio.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/crypto_portfolio.py b/crypto_portfolio.py index 6929b08..30e5c76 100644 --- a/crypto_portfolio.py +++ b/crypto_portfolio.py @@ -9,8 +9,12 @@ import mplfinance as mpf # a chave da API 'CHAVE_API_DEMO' if not os.path.exists('modulos/constantes.py'): chave_api = input('Introduza a chave da API Demo de CoinGecko: ') - with open('modulos/constantes.py', 'w') as f: - f.write(f'CHAVE_API_DEMO = \'{chave_api}\'\n') + if (not aux.validarChaveAPI(chave_api)): + print(f'erro na validação da chave API {chave_api}') + quit() + else: + with open('modulos/constantes.py', 'w') as f: + f.write(f'CHAVE_API_DEMO = \'{chave_api}\'\n') import modulos.coingecko_api as cgapi