frobar: Fix ramp doubles on 1.0

This commit is contained in:
Geoffrey Frogeye 2025-01-15 16:32:05 +01:00
parent c4fdd50a61
commit 04a08faa7f
Signed by: geoffrey
GPG key ID: C72403E7F82E6AD8

View file

@ -50,7 +50,10 @@ def ramp(p: float, states: str = " ▁▂▃▄▅▆▇█") -> str:
if p < 0:
return ""
d, m = divmod(p, 1.0)
return states[-1] * int(d) + states[round(m * (len(states) - 1))]
text = states[-1] * int(d)
if m > 0:
text += states[round(m * (len(states) - 1))]
return text
def clip(text: str, length: int = 30) -> str: