Human-readable byte size.
(n)
| 95 | |
| 96 | |
| 97 | def format_bytes(n): |
| 98 | """Human-readable byte size.""" |
| 99 | if n >= 1_048_576: |
| 100 | return f"{n / 1_048_576:.2f} MB" |
| 101 | if n >= 1024: |
| 102 | return f"{n / 1024:.1f} KB" |
| 103 | return f"{n} B" |
| 104 | |
| 105 | |
| 106 | def format_bytes_long(n): |
no outgoing calls
no test coverage detected