Skip to content

Commit

Permalink
Improved check_suffix() robustness to '' and "" (ultralytics#5192)
Browse files Browse the repository at this point in the history
* Improved check_suffix() robustness to `''` and `""`

* Cleanup
  • Loading branch information
glenn-jocher committed Oct 14, 2021
1 parent 8d97a01 commit 3823fd6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions utils/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,12 +293,14 @@ def check_imshow():


def check_suffix(file='yolov5s.pt', suffix=('.pt',), msg=''):
# Check file(s) for acceptable suffixes
# Check file(s) for acceptable suffix
if file and suffix:
if isinstance(suffix, str):
suffix = [suffix]
for f in file if isinstance(file, (list, tuple)) else [file]:
assert Path(f).suffix.lower() in suffix, f"{msg}{f} acceptable suffix is {suffix}"
s = Path(f).suffix.lower() # file suffix
if len(s):
assert s in suffix, f"{msg}{f} acceptable suffix is {suffix}"


def check_yaml(file, suffix=('.yaml', '.yml')):
Expand Down

0 comments on commit 3823fd6

Please sign in to comment.