Convert python int (bytes) to zfs size

    NOTE: http://src.illumos.org/source/xref/illumos-gate/usr/src/lib/pyzfs/common/util.py#114

def to_size(value, convert_to_human=True):
    '''
    Convert python int (bytes) to zfs size

    NOTE: http://src.illumos.org/source/xref/illumos-gate/usr/src/lib/pyzfs/common/util.py#114
    '''
    value = from_size(value)
    if value is None:
        value = 'none'

    if isinstance(value, Number) and value > 1024 and convert_to_human:
        v_power = int(math.floor(math.log(value, 1024)))
        v_multiplier = math.pow(1024, v_power)

        # NOTE: zfs is a bit odd on how it does the rounding,
        #       see libzfs implementation linked above
        v_size_float = float(value) / v_multiplier
        if v_size_float == int(v_size_float):
            value = "{:.0f}{}".format(
                v_size_float,
                zfs_size[v_power-1],
            )
        else:
            for v_precision in ["{:.2f}{}", "{:.1f}{}", "{:.0f}{}"]:
                v_size = v_precision.format(
                    v_size_float,
                    zfs_size[v_power-1],
                )
                if len(v_size) <= 5:
                    value = v_size
                    break

    return value