Merge pull request #17625 from netchampfaris/update-progress-bar-absolute

This commit is contained in:
Suraj Shetty 2022-07-27 16:55:49 +05:30 committed by GitHub
commit 3de50b1c84
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -559,7 +559,7 @@ def is_cli() -> bool:
return invoked_from_terminal
def update_progress_bar(txt, i, l):
def update_progress_bar(txt, i, l, absolute=False):
if os.environ.get("CI"):
if i == 0:
sys.stdout.write(txt)
@ -581,8 +581,9 @@ def update_progress_bar(txt, i, l):
complete = int(float(i + 1) / l * col)
completion_bar = ("=" * complete).ljust(col, " ")
percent_complete = str(int(float(i + 1) / l * 100))
sys.stdout.write(f"\r{txt}: [{completion_bar}] {percent_complete}%")
percent_complete = f"{str(int(float(i + 1) / l * 100))}%"
status = f"{i} of {l}" if absolute else percent_complete
sys.stdout.write(f"\r{txt}: [{completion_bar}] {status}")
sys.stdout.flush()