def pretty_bytes(b):
	"""
	Format a value of bytes to something sensible.
	"""

	if b >= 10 * (1024**3): # 10 GiB
		return '%0.0f GiB' % (float(b) / (1024**3))
	elif b >= (1024**3): # 1 GiB
		return '%0.1f GiB' % (float(b) / (1024**3))
	elif b >= 10 * (1024**2): # 10 MiB
		return '%0.0f MiB' % (float(b) / (1024**2))
	elif b >= (1024**2): # 1 MiB
		return '%0.1f MiB' % (float(b) / (1024**2))
	elif b >= 1024: # 1 KiB
		return '%0.0f KiB' % (float(b) / 1024)
	else:
		return '%d B' % b