def bytes2human(num):
    """
    Convert a size into a human readable format.
    """
    symbols = 'K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y'
    prefix = {}
    nume = ''
    if num < 0:
        num = num * -1
        nume = '-'
    for pos, sym in enumerate(symbols):
        prefix[sym] = 1 << (pos + 1) * 10
    for sym in reversed(symbols):
        if num >= prefix[sym]:
            value = '%.2f' % float(float(num) / float(prefix[sym]))
            return '%s%s%s' % (nume, value, sym)
    return '%s%.2fB' % (nume, num)
