From 47233f918d2b739b48c92c6dd3d71aaf59da83c2 Mon Sep 17 00:00:00 2001 From: Nicolas Thumann Date: Thu, 5 Dec 2024 16:47:07 +0100 Subject: [PATCH] Change: Rename attempts to request_attempts --- pontos/nvd/api.py | 12 ++++++------ pontos/nvd/cpe/api.py | 6 +++--- pontos/nvd/cve/api.py | 6 +++--- pontos/nvd/cve_changes/api.py | 6 +++--- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/pontos/nvd/api.py b/pontos/nvd/api.py index 3a798ffc5..edd726b7c 100644 --- a/pontos/nvd/api.py +++ b/pontos/nvd/api.py @@ -338,7 +338,7 @@ def __init__( token: Optional[str] = None, timeout: Optional[Timeout] = DEFAULT_TIMEOUT_CONFIG, rate_limit: bool = True, - attempts: int = 1, + request_attempts: int = 1, ) -> None: """ Create a new instance of the CVE API. @@ -354,7 +354,7 @@ def __init__( rolling 30 second window. See https://nvd.nist.gov/developers/start-here#divRateLimits Default: True. - attempts: The number of attempts per HTTP request. Defaults to 1. + request_attempts: The number of attempts per HTTP request. Defaults to 1. """ self._url = url self._token = token @@ -368,7 +368,7 @@ def __init__( self._request_count = 0 self._last_sleep = time.monotonic() - self._attempts = attempts + self._request_attempts = request_attempts def _request_headers(self) -> Headers: """ @@ -409,9 +409,9 @@ async def _get( """ headers = self._request_headers() - for retry in range(self._attempts): - if retry > 0: - delay = RETRY_DELAY**retry + for attempt in range(self._request_attempts): + if attempt > 0: + delay = RETRY_DELAY**attempt await asyncio.sleep(delay) await self._consider_rate_limit() diff --git a/pontos/nvd/cpe/api.py b/pontos/nvd/cpe/api.py index aea881d46..d397e50bb 100644 --- a/pontos/nvd/cpe/api.py +++ b/pontos/nvd/cpe/api.py @@ -61,7 +61,7 @@ def __init__( token: Optional[str] = None, timeout: Optional[Timeout] = DEFAULT_TIMEOUT_CONFIG, rate_limit: bool = True, - attempts: int = 1, + request_attempts: int = 1, ) -> None: """ Create a new instance of the CPE API. @@ -76,14 +76,14 @@ def __init__( rolling 30 second window. See https://nvd.nist.gov/developers/start-here#divRateLimits Default: True. - attempts: The number of attempts per HTTP request. Defaults to 1. + request_attempts: The number of attempts per HTTP request. Defaults to 1. """ super().__init__( DEFAULT_NIST_NVD_CPES_URL, token=token, timeout=timeout, rate_limit=rate_limit, - attempts=attempts, + request_attempts=request_attempts, ) async def cpe(self, cpe_name_id: Union[str, UUID]) -> CPE: diff --git a/pontos/nvd/cve/api.py b/pontos/nvd/cve/api.py index c52991c48..6dbce3dda 100644 --- a/pontos/nvd/cve/api.py +++ b/pontos/nvd/cve/api.py @@ -65,7 +65,7 @@ def __init__( token: Optional[str] = None, timeout: Optional[Timeout] = DEFAULT_TIMEOUT_CONFIG, rate_limit: bool = True, - attempts: int = 1, + request_attempts: int = 1, ) -> None: """ Create a new instance of the CVE API. @@ -80,14 +80,14 @@ def __init__( rolling 30 second window. See https://nvd.nist.gov/developers/start-here#divRateLimits Default: True. - attempts: The number of attempts per HTTP request. Defaults to 1. + request_attempts: The number of attempts per HTTP request. Defaults to 1. """ super().__init__( DEFAULT_NIST_NVD_CVES_URL, token=token, timeout=timeout, rate_limit=rate_limit, - attempts=attempts, + request_attempts=request_attempts, ) def cves( diff --git a/pontos/nvd/cve_changes/api.py b/pontos/nvd/cve_changes/api.py index 4d6671865..f6e37f6c6 100644 --- a/pontos/nvd/cve_changes/api.py +++ b/pontos/nvd/cve_changes/api.py @@ -55,7 +55,7 @@ def __init__( token: Optional[str] = None, timeout: Optional[Timeout] = DEFAULT_TIMEOUT_CONFIG, rate_limit: bool = True, - attempts: int = 1, + request_attempts: int = 1, ) -> None: """ Create a new instance of the CVE Change History API. @@ -70,14 +70,14 @@ def __init__( rolling 30 second window. See https://nvd.nist.gov/developers/start-here#divRateLimits Default: True. - attempts: The number of attempts per HTTP request. Defaults to 1. + request_attempts: The number of attempts per HTTP request. Defaults to 1. """ super().__init__( DEFAULT_NIST_NVD_CVE_HISTORY_URL, token=token, timeout=timeout, rate_limit=rate_limit, - attempts=attempts, + request_attempts=request_attempts, ) def changes(