def hr_bytes(nbytes):
    """Formats a given number of bytes for human readability."""
    multiplier = 0
    while abs(nbytes) >= 1000:
        nbytes /= 1024
        multiplier += 1
    return f'{nbytes:.1f}{["", "ki", "Mi", "Gi", "Ti", "Pi"][multiplier]}B'