fdutils/xpathbuilder/xf_func.py
def _xf(f_name, node, *values, **kwargs):
    """ (x)path (f)unction object to function conversion

    Args:
        f_name:
        node_string:
        value:
        insensitive:
        negate:

    Returns:

    """
    args_format = kwargs.pop('args_format', None) # args_format should include a {node} and a {values} attributes
    compare_to_node = kwargs.pop('compare_to_node', None)
    compare_to_value = kwargs.pop('compare_to_value', None)
    node_string = kwargs.pop('node_string', str(node))
    values = list(values)

    new_value, insensitive, negate, starts, contains, endswith, strip = get_modifier(*values, **kwargs)

    if new_value:
        values[0] = new_value

    if strip:
        node_string = value_strip(node_string)

    if insensitive:
        # make mutable
        values = [str(v).lower() for v in values]
        node_string = translate_lower(node_string)

    for i, v in enumerate(values):
        from .node import Node
        if isinstance(v, Node):
            values[i] = str(v)
        else:
            values[i] = '"' + v + '"'

    if starts and not f_name.startswith('start'):
        values[0] = value_startswith(node_string, values[0])
    elif contains and not f_name.startswith('contains'):
        values[0] = value_contains(node_string, values[0])
    elif endswith and not f_name.startswith('ends'):
        values[0] = value_endswith(node_string, values[0])

    if args_format:
        func_string = args_format.format(f_name=f_name, values=values, node=node_string)
    else:
        values = [node_string] + values
        func_string = '{}({})'.format(f_name, ', '.join(values))

    if not starts and not contains and not endswith:
        if compare_to_node:
            func_string = node_string + '=' + func_string
        elif compare_to_value:
            func_string = values[0] + '=' + func_string

    if negate:
        func_string = 'not(' + func_string + ')'

    return func_string
 (x)path (f)unction object to function conversion

    Args:
        f_name:
        node_string:
        value:
        insensitive:
        negate:

    Returns:

    
(x)path (f)unction object to function conversion
( x ) path ( f ) unction object to function conversion
def _xf(f_name, node, *values, **kwargs):
    args_format = kwargs.pop('args_format', None) 
    compare_to_node = kwargs.pop('compare_to_node', None)
    compare_to_value = kwargs.pop('compare_to_value', None)
    node_string = kwargs.pop('node_string', str(node))
    values = list(values)
    new_value, insensitive, negate, starts, contains, endswith, strip = get_modifier(*values, **kwargs)
    if new_value:
        values[0] = new_value
    if strip:
        node_string = value_strip(node_string)
    if insensitive:
        values = [str(v).lower() for v in values]
        node_string = translate_lower(node_string)
    for i, v in enumerate(values):
        from .node import Node
        if isinstance(v, Node):
            values[i] = str(v)
        else:
            values[i] = '"' + v + '"'
    if starts and not f_name.startswith('start'):
        values[0] = value_startswith(node_string, values[0])
    elif contains and not f_name.startswith('contains'):
        values[0] = value_contains(node_string, values[0])
    elif endswith and not f_name.startswith('ends'):
        values[0] = value_endswith(node_string, values[0])
    if args_format:
        func_string = args_format.format(f_name=f_name, values=values, node=node_string)
    else:
        values = [node_string] + values
        func_string = '{}({})'.format(f_name, ', '.join(values))
    if not starts and not contains and not endswith:
        if compare_to_node:
            func_string = node_string + '=' + func_string
        elif compare_to_value:
            func_string = values[0] + '=' + func_string
    if negate:
        func_string = 'not(' + func_string + ')'
    return func_string
def _xf ( f_name , node , * values , ** kwargs ) : args_format = kwargs . pop ( 'args_format' , None ) compare_to_node = kwargs . pop ( 'compare_to_node' , None ) compare_to_value = kwargs . pop ( 'compare_to_value' , None ) node_string = kwargs . pop ( 'node_string' , str ( node ) ) values = list ( values ) new_value , insensitive , negate , starts , contains , endswith , strip = get_modifier ( * values , ** kwargs ) if new_value : values [ 0 ] = new_value if strip : node_string = value_strip ( node_string ) if insensitive : values = [ str ( v ) . lower ( ) for v in values ] node_string = translate_lower ( node_string ) for i , v in enumerate ( values ) : from . node import Node if isinstance ( v , Node ) : values [ i ] = str ( v ) else : values [ i ] = '"' + v + '"' if starts and not f_name . startswith ( 'start' ) : values [ 0 ] = value_startswith ( node_string , values [ 0 ] ) elif contains and not f_name . startswith ( 'contains' ) : values [ 0 ] = value_contains ( node_string , values [ 0 ] ) elif endswith and not f_name . startswith ( 'ends' ) : values [ 0 ] = value_endswith ( node_string , values [ 0 ] ) if args_format : func_string = args_format . format ( f_name = f_name , values = values , node = node_string ) else : values = [ node_string ] + values func_string = '{}({})' . format ( f_name , ', ' . join ( values ) ) if not starts and not contains and not endswith : if compare_to_node : func_string = node_string + '=' + func_string elif compare_to_value : func_string = values [ 0 ] + '=' + func_string if negate : func_string = 'not(' + func_string + ')' return func_string
(x)path (f)unction object to function conversion
( x ) path ( f ) unction object to function conversion
""" (x)path (f)unction object to function conversion

    Args:
        f_name:
        node_string:
        value:
        insensitive:
        negate:

    Returns:

    """ # args_format should include a {node} and a {values} attributes # make mutable
None
f_name
None
node
node_string
None
value
None
insensitive
None
negate
None