

def _FormatHumanReadableSize(self, size):
    'Formats the size as a human readable string.\n\n    Args:\n      size: The size in bytes.\n\n    Returns:\n      A human readable string of the size.\n    '
    magnitude_1000 = 0
    size_1000 = float(size)
    while (size_1000 >= 1000):
        size_1000 /= 1000
        magnitude_1000 += 1
    magnitude_1024 = 0
    size_1024 = float(size)
    while (size_1024 >= 1024):
        size_1024 /= 1024
        magnitude_1024 += 1
    size_string_1000 = None
    if ((magnitude_1000 > 0) and (magnitude_1000 <= 7)):
        size_string_1000 = '{0:.1f}{1:s}'.format(size_1000, self._UNITS_1000[magnitude_1000])
    size_string_1024 = None
    if ((magnitude_1024 > 0) and (magnitude_1024 <= 7)):
        size_string_1024 = '{0:.1f}{1:s}'.format(size_1024, self._UNITS_1024[magnitude_1024])
    if ((not size_string_1000) or (not size_string_1024)):
        return '{0:d} B'.format(size)
    return '{0:s} / {1:s} ({2:d} B)'.format(size_string_1024, size_string_1000, size)

dataset/ETHPy150Open log2timeline/dfvfs/examples/recursive_hasher.py RecursiveHasherVolumeScannerMediator._FormatHumanReadableSize/original