Render a horizontal bar of the given fractional width.
(fraction, width=20, color=CYAN)
| 72 | |
| 73 | |
| 74 | def bar(fraction, width=20, color=CYAN): |
| 75 | """Render a horizontal bar of the given fractional width.""" |
| 76 | full_blocks = int(fraction * width) |
| 77 | remainder = (fraction * width) - full_blocks |
| 78 | partial_idx = int(remainder * 8) |
| 79 | result = BAR_FULL * full_blocks |
| 80 | if full_blocks < width: |
| 81 | result += BAR_CHARS[partial_idx] |
| 82 | result += " " * (width - full_blocks - 1) |
| 83 | return f"{color}{result}{RESET}" |
| 84 | |
| 85 | |
| 86 | def step(num, total, msg): |
no outgoing calls
no test coverage detected