INNER CODE UNIT · Python
_format_bytes_local
caipe-io/ai-platform-engineering · ai_platform_engineering/audit_service/main.py:457
def _format_bytes_local(value: int) -> str:
amount = float(value)
for unit in ("B", "KiB", "MiB", "GiB", "TiB"):
if amount < 1024 or unit == "TiB":
return f"{amount:.1f} {unit}" if unit != "B" else f"{int(amount)} B"
amount /= 1024
return f"{amount:.1f} TiB"
app = create_app()