(value: float | None)
| 510 | |
| 511 | |
| 512 | def format_bytes(value: float | None) -> str: |
| 513 | if value is None: |
| 514 | return "n/a" |
| 515 | units = ["B", "KB", "MB", "GB", "TB"] |
| 516 | index = 0 |
| 517 | current = value |
| 518 | while current >= 1024 and index < len(units) - 1: |
| 519 | current /= 1024 |
| 520 | index += 1 |
| 521 | return f"{current:.1f} {units[index]}" |
| 522 | |
| 523 | |
| 524 | def payload_etag(payload: Any) -> str: |