Stop EWW network statistics changing width
This commit is contained in:
parent
abbd3df78b
commit
3630cc2bf5
2 changed files with 6 additions and 4 deletions
|
@ -1,4 +1,4 @@
|
|||
#!/bin/env sh
|
||||
|
||||
# EWW doesn't seem to like listening to Python scripts directly, but this wrapper seems to work fine
|
||||
"$(dirname "$0")"/network-statistics "$@"
|
||||
python -OO "$(dirname "$0")"/network_statistics.py "$@"
|
||||
|
|
|
@ -35,10 +35,12 @@ class Status:
|
|||
|
||||
|
||||
def format_4_significant_digits(num: float) -> str:
|
||||
if num < 100:
|
||||
return f"{num:#.3g}"
|
||||
assert num >= 1.0, "Doesn't properly handle numbers below 1"
|
||||
if num < 999:
|
||||
return f"{num:04.3g}"
|
||||
if num < 1000:
|
||||
return f" {num:.3g}"
|
||||
# Above doesn't nicely handle the special case in [999.5 1000)
|
||||
return "0999"
|
||||
return f"{num:.4g}"
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue