From 1320ce183e3997c4e3a7bf23c22b9edb222519a4 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Fri, 23 Sep 2022 23:20:19 +0200 Subject: [PATCH] Update `is_url()` (#9566) Signed-off-by: Glenn Jocher Signed-off-by: Glenn Jocher --- utils/downloads.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/utils/downloads.py b/utils/downloads.py index dd2698f..bd49506 100644 --- a/utils/downloads.py +++ b/utils/downloads.py @@ -16,13 +16,13 @@ import requests import torch -def is_url(url, check_online=True): - # Check if online file exists +def is_url(url, check_exists=True): + # Check if string is URL and check if URL exists try: url = str(url) result = urllib.parse.urlparse(url) assert all([result.scheme, result.netloc, result.path]) # check if is url - return (urllib.request.urlopen(url).getcode() == 200) if check_online else True # check if exists online + return (urllib.request.urlopen(url).getcode() == 200) if check_exists else True # check if exists online except (AssertionError, urllib.request.HTTPError): return False