def human_filesize(bytes):
    """Human-readable file size.
    """
    for x in ['bytes', 'KB', 'MB', 'GB']:
        if bytes < 1024.0:
            return '%3.1f %s' % (bytes, x)
        bytes /= 1024.0
    return '%3.1f %s' % (bytes, 'TB')
