Skip to content

Commit

Permalink
Fix progressbar being too small
Browse files Browse the repository at this point in the history
  • Loading branch information
WyattBlue committed Feb 22, 2025
1 parent b63ae9c commit d575095
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
26 changes: 16 additions & 10 deletions auto_editor/utils/bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,20 +89,26 @@ def tick(self, index: float) -> None:
percent = round(progress * 100, 1)
p_pad = " " * (4 - len(str(percent)))
columns = get_terminal_size().columns
bar_len = max(1, columns - len_title - 32)
bar_len = max(1, columns - len_title - 35)
bar_str = self._bar_str(progress, bar_len)

bar = f" {self.icon}{title} {bar_str} {p_pad}{percent}% ETA {new_time}"

if len(bar) > columns - 2:
bar = bar[: columns - 2]
else:
bar += " " * (columns - len(bar) - 4)

sys.stdout.write(bar + "\r")
bar = f" {self.icon}{title} {bar_str} {p_pad}{percent}% ETA {new_time} \r"
sys.stdout.write(bar)

def start(self, total: float, title: str = "Please wait") -> None:
self.stack.append((title, len(title), total, time()))
len_title = 0
in_escape = False

for char in title:
if not in_escape:
if char == "\033":
in_escape = True
else:
len_title += 1
elif char == "m":
in_escape = False

self.stack.append((title, len_title, total, time()))

try:
self.tick(0)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ authors = [{ name = "WyattBlue", email = "[email protected]" }]
requires-python = ">=3.10,<3.14"
dependencies = [
"numpy>=1.24,<3.0",
"pyav==14.2.0",
"pyav==14.2.*",
]
keywords = [
"video", "audio", "media", "editor", "editing",
Expand Down

0 comments on commit d575095

Please sign in to comment.