import math


def human_readable_size(bytes):
    """
    Converts a size in bytes to a string containing a
    human-readable size in KB/MB/GB etc.
    """
    exp = int(math.log(bytes) / math.log(1024))
    units = "kMGTPE"
    pre = units[exp-1]
    return "%.1f %sB" % (bytes / (1024**exp), pre)