clint
clint copied to clipboard
Add format_str parameter for progress bar and mill
I wanted to add a way to customise the progress bar output, so implemented a parameter to pass a format string.
The details are in the commit message, but is shown here with formatting:
progress.Bar
, progress.bar
, and progress.mill
have a new format_str
parameter.
Named fields are used to facilitate the change. Using the new syntax, the original formats could be represented as below:
'{label}[{bar}] {completed}/{total} - {eta}'
'{label} {mill} {completed}/{total}'
str.format()
fails gracefully when named fields aren't present in the string,
allowing a given part of the string to be omitted. On the other hand, incorrect
field names cause a KeyError, preventing user error.
Note that when format_str=None
, the old templates are used so that any code that
modifies progress.BAR_TEMPLATE
, for example, is not affected by the change.
Also, the format_str
parameter does not require \r
at the end, it is appended
automatically.
Yes please. Is there anything preventing this from being merged (other than the conflict in AUTHORS
that is trivial to resolve)?
Redundant merge commit much. :P You should have used git pull --rebase
.
I clicked the resolve conflict button in the UI since you mentioned it. I'll bother rebasing if it a) looks like it'll be merged and b) won't be squashed…