GeezerVison is showing github.com — docs(readme): gradient percentage on the plain race lane, history wor… · wolph/python-progressbar@c10b76b
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: README.md +3-4Lines changed: 3 additions & 4 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -380,10 +380,9 @@ if __name__ == '__main__': |
380 | 380 | The features above are the flashy half. The other half is why the |
381 | 381 | package has survived since 2012: |
382 | 382 |
|
383 | | -- Maintained since February 2012, with 111 releases on PyPI since |
384 | | - 2013. The lineage goes back further: this is the continuation of the |
385 | | - original `progressbar` package, on PyPI since 2006, and it still |
386 | | - works as a drop-in replacement for it. |
| 383 | +- Supported non-stop since 2012, with 111 releases on PyPI, and since |
| 384 | + 2008 before that as the original `progressbar` library, which |
| 385 | + progressbar2 still replaces drop-in. |
387 | 386 | - 1131 tests at 100% branch coverage, enforced in CI on every commit. |
388 | 387 | - Fully typed (PEP 561 `py.typed`), so your type checker sees the real |
389 | 388 | signatures. |
|
Collapse file
Copy file name to clipboardExpand all lines: docs/_static/demos/readme-race.svg +1-1Lines changed: 1 addition & 1 deletion - Display the source diff
- Display the rich diff
Collapse file
Copy file name to clipboardExpand all lines: scripts/render_race.py +7Lines changed: 7 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -141,6 +141,13 @@ def race_frames(results: dict[str, typing.Any]) -> list[list[str]]: |
141 | 141 | fraction = min(1.0, t / total) |
142 | 142 | filled = round(fraction * BAR_WIDTH) |
143 | 143 | pct = f'{fraction * 100:3.0f}%' |
| 144 | + if lane == 'progressbar2': |
| 145 | + # The full bar's default widgets color the percentage |
| 146 | + # readout with the red->green progress gradient |
| 147 | + # (widgets.Bar's `fg=colors.gradient` default), so the |
| 148 | + # plain lane wears that here too. The fill stays plain |
| 149 | + # '#', which is also faithful to the default look. |
| 150 | + pct = f'{_sgr(*_gradient_rgb(fraction))}{pct}{RESET}' |
144 | 151 | suffix = f' {total * 1000:.1f} ms' if fraction >= 1.0 else '' |
145 | 152 | lines.append( |
146 | 153 | f'{RESET}{lane:<{LABEL_WIDTH}} {pct} ' |
|