@staticmethod
def _human_size(size_bytes):
    """
        format a size in bytes into a 'human' file size, e.g. bytes, KB, MB, GB, TB, PB
        Note that bytes/KB will be reported in whole numbers but MB and above will have
        greater precision e.g. 1 byte, 43 bytes, 443 KB, 4.3 MB, 4.43 GB, etc

        Taken from:
        https://stackoverflow.com/questions/1094841/reusable-library-to-get-human-readable-version-of-file-size
        """
    num = float(size_bytes)
    if num < 0:
        raise ValueError('No negative values supported.')
    if num <= 1:
        return '%d byte' % num
    suffixes_table = [('bytes', 0), ('KB', 0), ('MB', 1), ('GB', 2), ('TB',
        2), ('PB', 2)]
    for suffix, precision in suffixes_table:
        if num < 1024.0:
            break
        num /= 1024.0
    if precision == 0:
        formatted_size = '%d' % num
    else:
        formatted_size = str(round(num, ndigits=precision))
    return '%s %s' % (formatted_size, suffix)
