fix: ZeroDivisionError: integer division or modulo by zero

This commit is contained in:
Swann
2020-07-07 15:50:05 +02:00
parent 154aaf71c8
commit 9e64584f2d

View File

@ -50,6 +50,8 @@ def printProgressBar(iteration, total, prefix='', suffix='', decimals=1, length=
From here: From here:
https://gist.github.com/greenstick/b23e475d2bfdc3a82e34eaa1f6781ee4 https://gist.github.com/greenstick/b23e475d2bfdc3a82e34eaa1f6781ee4
""" """
if total == 0:
return ""
filledLength = int(length * iteration // total) filledLength = int(length * iteration // total)
bar = fill * filledLength + fill_empty * (length - filledLength) bar = fill * filledLength + fill_empty * (length - filledLength)
return f"{prefix} |{bar}| {iteration}/{total}{suffix}" return f"{prefix} |{bar}| {iteration}/{total}{suffix}"