ultralytics 8.3.8 replace contextlib with try for speed (#16782)
Signed-off-by: UltralyticsAssistant <web@ultralytics.com> Co-authored-by: UltralyticsAssistant <web@ultralytics.com>
This commit is contained in:
parent
1e6c454460
commit
a6a577961f
12 changed files with 115 additions and 88 deletions
|
|
@ -1,6 +1,5 @@
|
|||
# Ultralytics YOLO 🚀, AGPL-3.0 license
|
||||
|
||||
import contextlib
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
|
|
@ -53,7 +52,7 @@ def is_url(url, check=False):
|
|||
valid = is_url("https://www.example.com")
|
||||
```
|
||||
"""
|
||||
with contextlib.suppress(Exception):
|
||||
try:
|
||||
url = str(url)
|
||||
result = parse.urlparse(url)
|
||||
assert all([result.scheme, result.netloc]) # check if is url
|
||||
|
|
@ -61,7 +60,8 @@ def is_url(url, check=False):
|
|||
with request.urlopen(url) as response:
|
||||
return response.getcode() == 200 # check if exists online
|
||||
return True
|
||||
return False
|
||||
except: # noqa E722
|
||||
return False
|
||||
|
||||
|
||||
def delete_dsstore(path, files_to_delete=(".DS_Store", "__MACOSX")):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue