Skip to content

Commit

Permalink
ensure fixed size for meter
Browse files Browse the repository at this point in the history
  • Loading branch information
esheldon committed Oct 6, 2024
1 parent 66db3c7 commit a019c76
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions esutil/pbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,13 @@ def format_meter(n, total, elapsed, n_bars=20):

left_str = format_interval(elapsed / n * (total-n)) if n else '?'

return '|%s| %d/%d %s [elapsed: %s left: %s %s]' % (
bar, n, total, percentage, elapsed_str, left_str, rate_str)
totstr = str(total)
nfmt = '%' + str(len(totstr)) + 'd'
meter_fmt = '|%s| ' + nfmt + '/' + nfmt + ' %s [%s<%s %s]'

return meter_fmt % (
bar, n, total, percentage, elapsed_str, left_str, rate_str
)

else:
return '%d [elapsed: %s]' % (n, elapsed_str)
Expand Down

0 comments on commit a019c76

Please sign in to comment.