Skip to content

Commit

Permalink
feat: added with_item boolean to progress bar
Browse files Browse the repository at this point in the history
  • Loading branch information
RonTamG committed Feb 6, 2024
1 parent 12fbbff commit b3c0ae2
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/progress_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def get_cursor_position():
return (-1, -1)


def progressbar(it, count, prefix="", size=60): # Python3.6+
def progressbar(it, count, prefix="", size=60, with_item=True): # Python3.6+
"""
displays a progress bar for an iterator
Expand All @@ -78,7 +78,9 @@ def show(current, x, y, item=""):
print(CLEAR, end="", flush=True)

filled = int(size * current / count)
line = f"{prefix}[{'#' * filled}{('.' * (size - filled))}] {current}/{count} [{item}]" # noqa: E501
line = f"{prefix}[{'#' * filled}{('.' * (size - filled))}] {current}/{count}" # noqa: E501
if with_item:
line += f" [{item}]"
print(line, end="", flush=True)

return len(line)
Expand Down

0 comments on commit b3c0ae2

Please sign in to comment.