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>
pull/9909/head
SSTato 2022-10-24 22:20:47 +08:00 committed by GitHub
parent eef90572bf
commit fba61e5583
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -344,7 +344,7 @@ class LoadStreams:
self.img_size = img_size
self.stride = stride
self.vid_stride = vid_stride # video frame-rate stride
sources = Path(sources).read_text().rsplit() if Path(sources).is_file() else [sources]
sources = Path(sources).read_text().rsplit() if os.path.isfile(sources) else [sources]
n = len(sources)
self.sources = [clean_str(x) for x in sources] # clean source names for later
self.imgs, self.fps, self.frames, self.threads = [None] * n, [0] * n, [0] * n, [None] * n

View File

@ -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