def sizeof_fmt(num):
    """
    Returns the human readable version of a file size

    :param num:
    :return:
    """
    for item in ['bytes', 'KB', 'MB', 'GB']:
        if num < 1024.0:
            return "%3.1f%s" % (num, item)
        num /= 1024.0
    return "%3.1f%s" % (num, 'TB')
dataset/ETHPy150Open vmware/pyvmomi-community-samples/samples/list_dc_datastore_info.py/sizeof_fmt/original