From b92e04f5e9721676491104b49351b774c02101c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20R=C3=B6hrig?= Date: Wed, 29 Jul 2020 12:04:28 +0200 Subject: [PATCH 01/12] added cleanup_payload function to Client --- pyracing/client.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/pyracing/client.py b/pyracing/client.py index ba6a715..514066f 100644 --- a/pyracing/client.py +++ b/pyracing/client.py @@ -60,13 +60,15 @@ async def _authenticate(self): else: self.log.info('Login successful') - async def _build_request(self, url, params): + async def _build_request(self, url, payload): """ Builds the final GET request from url and params """ if not self.session.cookies.__bool__(): self.log.info("No cookies in cookie jar.") await self._authenticate() + params = self.cleanup_payload(payload) + self.log.info(f'Request being sent to: {url} with params: {params}') response = await self.session.get( @@ -782,3 +784,11 @@ async def yearly_stats(self, cust_id): return [] return [career_stats.YearlyStats(x) for x in response.json()] + + @staticmethod + def cleanup_payload(payload): + for key in payload.copy(): + if payload.get(key) is None: + delattr(payload, key) + + return payload From 7f53465d83f6a9852d0cb45f3a567ffacc5fa206 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20R=C3=B6hrig?= Date: Wed, 29 Jul 2020 12:04:51 +0200 Subject: [PATCH 02/12] improved parse_encode check --- pyracing/helpers.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pyracing/helpers.py b/pyracing/helpers.py index 5319fe0..25af86f 100644 --- a/pyracing/helpers.py +++ b/pyracing/helpers.py @@ -31,7 +31,6 @@ def now_five_min_floor(): def parse_encode(string): - if not type(string) is str: + if not isinstance(string, str): return '' - return urllib.parse.unquote(string).replace('+', ' ') From 04f6ba0ba44383a8c5b2cac4542f15aa415d122e Mon Sep 17 00:00:00 2001 From: NoHeDidn't Date: Thu, 30 Jul 2020 18:09:47 +0200 Subject: [PATCH 03/12] Update pyracing/client.py --- pyracing/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyracing/client.py b/pyracing/client.py index 514066f..ebe5155 100644 --- a/pyracing/client.py +++ b/pyracing/client.py @@ -60,7 +60,7 @@ async def _authenticate(self): else: self.log.info('Login successful') - async def _build_request(self, url, payload): + async def _build_request(self, url, params): """ Builds the final GET request from url and params """ if not self.session.cookies.__bool__(): From 4abc50882c1c56bc1c23e9decb8ea52d33987491 Mon Sep 17 00:00:00 2001 From: NoHeDidn't Date: Thu, 30 Jul 2020 18:09:57 +0200 Subject: [PATCH 04/12] Update pyracing/client.py --- pyracing/client.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pyracing/client.py b/pyracing/client.py index ebe5155..38b6852 100644 --- a/pyracing/client.py +++ b/pyracing/client.py @@ -67,7 +67,6 @@ async def _build_request(self, url, params): self.log.info("No cookies in cookie jar.") await self._authenticate() - params = self.cleanup_payload(payload) self.log.info(f'Request being sent to: {url} with params: {params}') From b72f70a164f1de7ee3e6b162fee396041b1da143 Mon Sep 17 00:00:00 2001 From: NoHeDidn't Date: Thu, 30 Jul 2020 18:10:10 +0200 Subject: [PATCH 05/12] Update pyracing/client.py --- pyracing/client.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pyracing/client.py b/pyracing/client.py index 38b6852..d1acbab 100644 --- a/pyracing/client.py +++ b/pyracing/client.py @@ -67,7 +67,6 @@ async def _build_request(self, url, params): self.log.info("No cookies in cookie jar.") await self._authenticate() - self.log.info(f'Request being sent to: {url} with params: {params}') response = await self.session.get( From f54386e5687a8217c1d597981dbcf265954567d9 Mon Sep 17 00:00:00 2001 From: NoHeDidn't Date: Thu, 30 Jul 2020 18:10:22 +0200 Subject: [PATCH 06/12] Update pyracing/client.py --- pyracing/client.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pyracing/client.py b/pyracing/client.py index d1acbab..2203ff1 100644 --- a/pyracing/client.py +++ b/pyracing/client.py @@ -782,7 +782,6 @@ async def yearly_stats(self, cust_id): return [] return [career_stats.YearlyStats(x) for x in response.json()] - @staticmethod def cleanup_payload(payload): for key in payload.copy(): From 533e1bf450110e45df048456db355007367ecc2b Mon Sep 17 00:00:00 2001 From: NoHeDidn't Date: Thu, 30 Jul 2020 18:10:31 +0200 Subject: [PATCH 07/12] Update pyracing/client.py --- pyracing/client.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pyracing/client.py b/pyracing/client.py index 2203ff1..b8dd4e6 100644 --- a/pyracing/client.py +++ b/pyracing/client.py @@ -782,7 +782,6 @@ async def yearly_stats(self, cust_id): return [] return [career_stats.YearlyStats(x) for x in response.json()] - @staticmethod def cleanup_payload(payload): for key in payload.copy(): if payload.get(key) is None: From b0362124375a01353a8503a90c1873c116939de3 Mon Sep 17 00:00:00 2001 From: NoHeDidn't Date: Thu, 30 Jul 2020 18:10:58 +0200 Subject: [PATCH 08/12] Update pyracing/client.py --- pyracing/client.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pyracing/client.py b/pyracing/client.py index b8dd4e6..84a1575 100644 --- a/pyracing/client.py +++ b/pyracing/client.py @@ -783,7 +783,6 @@ async def yearly_stats(self, cust_id): return [career_stats.YearlyStats(x) for x in response.json()] def cleanup_payload(payload): - for key in payload.copy(): if payload.get(key) is None: delattr(payload, key) From a3b1d1fc512188d05a71dc8ad0e9dbe503a22463 Mon Sep 17 00:00:00 2001 From: NoHeDidn't Date: Thu, 30 Jul 2020 18:11:14 +0200 Subject: [PATCH 09/12] Update pyracing/client.py --- pyracing/client.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pyracing/client.py b/pyracing/client.py index 84a1575..9f8a51f 100644 --- a/pyracing/client.py +++ b/pyracing/client.py @@ -783,7 +783,6 @@ async def yearly_stats(self, cust_id): return [career_stats.YearlyStats(x) for x in response.json()] def cleanup_payload(payload): - if payload.get(key) is None: delattr(payload, key) return payload From 5436e4c31f3ce41f81dafd695a6804f47584cd8a Mon Sep 17 00:00:00 2001 From: NoHeDidn't Date: Thu, 30 Jul 2020 18:11:22 +0200 Subject: [PATCH 10/12] Update pyracing/client.py --- pyracing/client.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pyracing/client.py b/pyracing/client.py index 9f8a51f..92620ca 100644 --- a/pyracing/client.py +++ b/pyracing/client.py @@ -783,6 +783,5 @@ async def yearly_stats(self, cust_id): return [career_stats.YearlyStats(x) for x in response.json()] def cleanup_payload(payload): - delattr(payload, key) return payload From ae75917f82deb0f117789efd66216f794e18bd50 Mon Sep 17 00:00:00 2001 From: NoHeDidn't Date: Thu, 30 Jul 2020 18:11:29 +0200 Subject: [PATCH 11/12] Update pyracing/client.py --- pyracing/client.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pyracing/client.py b/pyracing/client.py index 92620ca..5edccc2 100644 --- a/pyracing/client.py +++ b/pyracing/client.py @@ -783,5 +783,4 @@ async def yearly_stats(self, cust_id): return [career_stats.YearlyStats(x) for x in response.json()] def cleanup_payload(payload): - return payload From ff6d576a1383d92998d4b673e42c77bfa903a541 Mon Sep 17 00:00:00 2001 From: NoHeDidn't Date: Thu, 30 Jul 2020 18:11:35 +0200 Subject: [PATCH 12/12] Update pyracing/client.py --- pyracing/client.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pyracing/client.py b/pyracing/client.py index 5edccc2..82a9159 100644 --- a/pyracing/client.py +++ b/pyracing/client.py @@ -783,4 +783,3 @@ async def yearly_stats(self, cust_id): return [career_stats.YearlyStats(x) for x in response.json()] def cleanup_payload(payload): - return payload