Windows Python 3.7 .isfile() fix (#9879)
* Update dataloaders.py Signed-off-by: SSTato <1210546396@qq.com> * Update general.py Signed-off-by: SSTato <1210546396@qq.com> * Update general.py Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com> * Update dataloaders.py Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com> * Update dataloaders.py Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com> * Update general.py Signed-off-by: SSTato <1210546396@qq.com> * Update ci-testing.yml Signed-off-by: SSTato <1210546396@qq.com> * Update ci-testing.yml Signed-off-by: SSTato <1210546396@qq.com> * Update ci-testing.yml Signed-off-by: SSTato <1210546396@qq.com> * Update general.py Signed-off-by: SSTato <1210546396@qq.com> * Update general.py Signed-off-by: SSTato <1210546396@qq.com> * Update dataloaders.py Signed-off-by: SSTato <1210546396@qq.com> Signed-off-by: SSTato <1210546396@qq.com> Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com> Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
This commit is contained in:
1 parent
eef90572bf
commit
fba61e5583
2 files changed
+4
-4
No files matched your search
+3
-3
@@ -426,12 +426,12 @@ def check_file(file, suffix=''):
|
||||
# Search/download file (if necessary) and return path
|
||||
check_suffix(file, suffix) # optional
|
||||
file = str(file) # convert to str()
|
||||
if Path(file).is_file() or not file: # exists
|
||||
if os.path.isfile(file) or not file: # exists
|
||||
return file
|
||||
elif file.startswith(('http:/', 'https:/')): # download
|
||||
url = file # warning: Pathlib turns :// -> :/
|
||||
file = Path(urllib.parse.unquote(file).split('?')[0]).name # '%2F' to '/', split https://url.com/file.txt?auth
|
||||
if Path(file).is_file():
|
||||
if os.path.isfile(file):
|
||||
LOGGER.info(f'Found {url} locally at {file}') # file already exists
|
||||
else:
|
||||
LOGGER.info(f'Downloading {url} to {file}...')
|
||||
@@ -586,7 +586,7 @@ def download(url, dir='.', unzip=True, delete=True, curl=False, threads=1, retry
|
||||
def download_one(url, dir):
|
||||
# Download 1 file
|
||||
success = True
|
||||
if Path(url).is_file():
|
||||
if os.path.isfile(url):
|
||||
f = Path(url) # filename
|
||||
else: # does not exist
|
||||
f = dir / Path(url).name
|
||||
|
||||
Reference in new issue
Block a user