From eb5a7b61d4e5b56de7d05f3d8859ae3af0d80e1d Mon Sep 17 00:00:00 2001 From: c0d3d3v Date: Wed, 1 May 2024 19:36:21 +0200 Subject: [PATCH] reformat request_helper --- moodle_dl/moodle/request_helper.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/moodle_dl/moodle/request_helper.py b/moodle_dl/moodle/request_helper.py index 7bcca94..cf7e3dc 100644 --- a/moodle_dl/moodle/request_helper.py +++ b/moodle_dl/moodle/request_helper.py @@ -62,7 +62,9 @@ def post_URL(self, url: str, data: Dict[str, str] = None, cookie_jar_path: str = if data is not None: data_urlencoded = self.recursive_urlencode(data) - session = SslHelper.custom_requests_session(self.opts.skip_cert_verify, self.opts.allow_insecure_ssl, self.opts.use_all_ciphers) + session = SslHelper.custom_requests_session( + self.opts.skip_cert_verify, self.opts.allow_insecure_ssl, self.opts.use_all_ciphers + ) if cookie_jar_path is not None: session.cookies = MoodleDLCookieJar(cookie_jar_path) @@ -91,7 +93,9 @@ def get_URL(self, url: str, cookie_jar_path: str = None): @return: The resulting Response object. """ - session = SslHelper.custom_requests_session(self.opts.skip_cert_verify, self.opts.allow_insecure_ssl, self.opts.use_all_ciphers) + session = SslHelper.custom_requests_session( + self.opts.skip_cert_verify, self.opts.allow_insecure_ssl, self.opts.use_all_ciphers + ) if cookie_jar_path is not None: session.cookies = MoodleDLCookieJar(cookie_jar_path) @@ -123,7 +127,9 @@ async def async_post(self, function: str, data: Dict[str, str] = None, timeout: data = self._get_POST_DATA(function, self.token, data) data_urlencoded = self.recursive_urlencode(data) url = self._get_REST_POST_URL(self.url_base, function) - ssl_context = SslHelper.get_ssl_context(self.opts.skip_cert_verify, self.opts.allow_insecure_ssl, self.opts.use_all_ciphers) + ssl_context = SslHelper.get_ssl_context( + self.opts.skip_cert_verify, self.opts.allow_insecure_ssl, self.opts.use_all_ciphers + ) error_ctr = 0 async with self.semaphore, aiohttp.ClientSession() as session: @@ -181,7 +187,9 @@ def post(self, function: str, data: Dict[str, str] = None, timeout: int = 60) -> data_urlencoded = self.recursive_urlencode(data) url = self._get_REST_POST_URL(self.url_base, function) - session = SslHelper.custom_requests_session(self.opts.skip_cert_verify, self.opts.allow_insecure_ssl, self.opts.use_all_ciphers) + session = SslHelper.custom_requests_session( + self.opts.skip_cert_verify, self.opts.allow_insecure_ssl, self.opts.use_all_ciphers + ) error_ctr = 0 while error_ctr <= self.MAX_RETRIES: try: @@ -249,7 +257,9 @@ def get_login(self, data: Dict[str, str]) -> object: @return: The JSON response returned by the Moodle System, already checked for errors. """ - session = SslHelper.custom_requests_session(self.opts.skip_cert_verify, self.opts.allow_insecure_ssl, self.opts.use_all_ciphers) + session = SslHelper.custom_requests_session( + self.opts.skip_cert_verify, self.opts.allow_insecure_ssl, self.opts.use_all_ciphers + ) try: response = session.post( f'{self.url_base}login/token.php',