Make sure we provide sane human-readable size for small sizes like 1 byte or 10
bytes. With this change, for sizes less than 512 we'll print X bytes, while for
larger sized we'll print 0.YKiB.
Change-Id: I7a5a32ed3a9dc26fb754299c55d7dbffdf531a37
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
def human_size(size):
""" Transform size in bytes into a human-readable form. """
+ if size == 1:
+ return "1 byte"
+
+ if size < 512:
+ return "%d bytes" % size
+
for modifier in ["KiB", "MiB", "GiB", "TiB"]:
size /= 1024.0
if size < 1024: