From 931b799d14b141d76e186443fa41a7295fd54ccb Mon Sep 17 00:00:00 2001 From: Ivan Pozdeev Date: Tue, 4 Aug 2026 13:06:33 +0300 Subject: [PATCH] Refactor into a holder class like other utility methods --- plugins/python-build/scripts/add_cpython.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/plugins/python-build/scripts/add_cpython.py b/plugins/python-build/scripts/add_cpython.py index 77c1dfe9..46555136 100755 --- a/plugins/python-build/scripts/add_cpython.py +++ b/plugins/python-build/scripts/add_cpython.py @@ -34,12 +34,6 @@ import tqdm logger = logging.getLogger(__name__) -def _fetch(url: str) -> requests.Response: - response = requests.get(url, timeout=30) - response.raise_for_status() - return response - - CUTOFF_VERSION=packaging.version.Version('3.10') EXCLUDED_VERSIONS= { } @@ -549,7 +543,7 @@ class OpenSSLVersionsDirectory(KeyedList[_OpenSSLVersionInfo, packaging.version. url = "https://api.github.com/repos/openssl/openssl/releases" while url: - response = _fetch(url) + response = Requests.get(url) matching = [ release for release in response.json() @@ -574,7 +568,7 @@ class OpenSSLVersionsDirectory(KeyedList[_OpenSSLVersionInfo, packaging.version. for asset in j_release['assets'] if urllib.parse.urlparse(asset['browser_download_url']).path.split('/')[-1].endswith('.sha256') ) - shasum_text = _fetch(shasum_url).text + shasum_text = Requests.get(shasum_url).text shasum_data = jc.parse("hashsum", shasum_text, quiet=True)[0] package_hash, package_filename = shasum_data["hash"], shasum_data["filename"] del shasum_data, shasum_text, shasum_url @@ -748,6 +742,13 @@ class Url: h.update(c) return h.hexdigest() +class Requests: + @staticmethod + def get(url: str) -> requests.Response: + response = requests.get(url, timeout=30) + response.raise_for_status() + return response + if __name__ == "__main__": #sys.excepthook seems to have no effect in Github Actions