Skip to content

Commit c70bb85

Browse files
authored
Merge pull request #6160 from richtja/aurl_deprecation
Aurl utility deprecation
2 parents 53f6136 + bbaa79c commit c70bb85

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

avocado/utils/aurl.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,14 @@
1717
1818
The strange name is to avoid accidental naming collisions in code.
1919
"""
20-
20+
import logging
2121
import urllib.parse
2222

2323
#: The most common schemes (protocols) used in URLs
2424
COMMON_SCHEMES = ("http", "https", "ftp", "git")
2525

26+
LOG = logging.getLogger(__name__)
27+
2628

2729
def is_url(path):
2830
"""Return `True` if path looks like an URL of common protocols.
@@ -32,5 +34,8 @@ def is_url(path):
3234
:param path: path to check.
3335
:rtype: Boolean.
3436
"""
37+
LOG.warning(
38+
"The aurl utility is deprecated and will be removed after the next LTS release."
39+
)
3540
url_parts = urllib.parse.urlparse(path)
3641
return url_parts[0] in COMMON_SCHEMES

avocado/utils/download.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@
2222
import shutil
2323
import socket
2424
import sys
25+
import urllib.parse
2526
from multiprocessing import Process
2627
from urllib.error import HTTPError
2728
from urllib.request import urlopen
2829

29-
from avocado.utils import aurl, crypto, output
30+
from avocado.utils import crypto, output
3031

3132
log = logging.getLogger(__name__)
3233

@@ -148,7 +149,7 @@ def _get_file(src, dst, permissions=None):
148149
if src == dst:
149150
return None
150151

151-
if aurl.is_url(src):
152+
if urllib.parse.urlparse(src)[0] in ["http", "https"]:
152153
url_download(src, dst)
153154
else:
154155
shutil.copyfile(src, dst)

avocado/utils/path.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@
1919
import os
2020
import stat
2121
import tempfile
22-
23-
from avocado.utils import aurl
22+
import urllib
2423

2524
SHEBANG = "#!"
2625

@@ -54,7 +53,12 @@ def get_path(base_path, user_path):
5453
:param base_path: The base path of relative user specified paths.
5554
:param user_path: The user specified path.
5655
"""
57-
if os.path.isabs(user_path) or aurl.is_url(user_path):
56+
if os.path.isabs(user_path) or urllib.parse.urlparse(user_path)[0] in [
57+
"http",
58+
"https",
59+
"ftp",
60+
"file",
61+
]:
5862
return user_path
5963
return os.path.join(base_path, user_path)
6064

0 commit comments

Comments
 (0)