def _auto(direction, name, value, source='auto', convert_to_human=True):
    '''
    Internal magic for from_auto and to_auto
    '''
    # NOTE: check direction
    if direction not in ['to', 'from']:
        return value

    # NOTE: collect property data
    props = property_data_zpool()
    if source == 'zfs':
        props = property_data_zfs()
    elif source == 'auto':
        props.update(property_data_zfs())

    # NOTE: figure out the conversion type
    value_type = props[name]['type'] if name in props else 'str'

    # NOTE: convert
    if value_type == 'size' and direction == 'to':
        return globals()['{}_{}'.format(direction, value_type)](value, convert_to_human)

    return globals()['{}_{}'.format(direction, value_type)](value)
def _auto ( direction , name , value , source = 'auto' , convert_to_human = True ) : if direction not in [ 'to' , 'from' ] : return value props = property_data_zpool ( ) if source == 'zfs' : props = property_data_zfs ( ) elif source == 'auto' : props . update ( property_data_zfs ( ) ) value_type = props [ name ] [ 'type' ] if name in props else 'str' if value_type == 'size' and direction == 'to' : return globals ( ) [ '{}_{}' . format ( direction , value_type ) ] ( value , convert_to_human ) return globals ( ) [ '{}_{}' . format ( direction , value_type ) ] ( value )
Internal magic for from_auto and to_auto