From c305ceb55f69af6b77a66fd9ef31a0a988b20ed2 Mon Sep 17 00:00:00 2001 From: Sergei Silnov Date: Mon, 11 Jan 2021 16:58:21 +0100 Subject: [PATCH] idf_tools.py: avoid splittype call deprecated in python3.8 Closes https://github.com/espressif/esp-idf/issues/6200 --- tools/idf_tools.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tools/idf_tools.py b/tools/idf_tools.py index 993a84b87e..5eed405a1a 100755 --- a/tools/idf_tools.py +++ b/tools/idf_tools.py @@ -64,11 +64,10 @@ except ImportError: pass try: - from urllib.parse import splittype from urllib.request import urlopen from urllib.error import ContentTooShortError except ImportError: - from urllib import urlopen, splittype, ContentTooShortError + from urllib import urlopen, ContentTooShortError try: from exceptions import WindowsError @@ -305,6 +304,14 @@ def unpack(filename, destination): archive_obj.extractall(destination) +def splittype(url): + match = re.match('([^/:]+):(.*)', url, re.DOTALL) + if match: + scheme, data = match.groups() + return scheme.lower(), data + return None, url + + # An alternative version of urlretrieve which takes SSL context as an argument def urlretrieve_ctx(url, filename, reporthook=None, data=None, context=None): url_type, path = splittype(url)