(content, variables_mapping, functions_mapping)
return content
parse string content with functions mapping.

    Args:
        content (str): string content to be parsed.
        variables_mapping (dict): variables mapping.
        functions_mapping (dict): functions mapping.

    Returns:
        str: parsed string content.

    Examples:
        >>> content = "abc${add_one(3)}def"
        >>> functions_mapping = {"add_one": lambda x: x + 1}
        >>> parse_string_functions(content, functions_mapping)
            "abc4def"
parse string content with functions mapping.
parse string content with functions mapping .
def parse_string_functions(content, variables_mapping, functions_mapping):
    """ parse string content with functions mapping.

    Args:
        content (str): string content to be parsed.
        variables_mapping (dict): variables mapping.
        functions_mapping (dict): functions mapping.

    Returns:
        str: parsed string content.

    Examples:
        >>> content = "abc${add_one(3)}def"
        >>> functions_mapping = {"add_one": lambda x: x + 1}
        >>> parse_string_functions(content, functions_mapping)
            "abc4def"

    """
    functions_list = extract_functions(content)
    for func_content in functions_list:
        function_meta = parse_function(func_content)
        func_name = function_meta["func_name"]

        args = function_meta.get("args", [])
        kwargs = function_meta.get("kwargs", {})
        args = parse_data(args, variables_mapping, functions_mapping)
        kwargs = parse_data(kwargs, variables_mapping, functions_mapping)

        if func_name in ["parameterize", "P"]:
            if len(args) != 1 or kwargs:
                raise exceptions.ParamsError("P() should only pass in one argument!")
            from . import loader
            eval_value = loader.load_csv_file(args[0])
        elif func_name in ["environ", "ENV"]:
            if len(args) != 1 or kwargs:
                raise exceptions.ParamsError("ENV() should only pass in one argument!")
            eval_value = utils.get_os_environ(args[0])
        else:
            func = get_mapping_function(func_name, functions_mapping)
            eval_value = func(*args, **kwargs)

        func_content = "${" + func_content + "}"
        if func_content == content:
            # content is a function, e.g. "${add_one(3)}"
            content = eval_value
        else:
            # content contains one or many functions, e.g. "abc${add_one(3)}def"
            content = content.replace(
                func_content,
                str(eval_value), 1
            )

    return content
def parse_string_functions ( content , variables_mapping , functions_mapping ) : functions_list = extract_functions ( content ) for func_content in functions_list : function_meta = parse_function ( func_content ) func_name = function_meta [ "func_name" ] args = function_meta . get ( "args" , [ ] ) kwargs = function_meta . get ( "kwargs" , { } ) args = parse_data ( args , variables_mapping , functions_mapping ) kwargs = parse_data ( kwargs , variables_mapping , functions_mapping ) if func_name in [ "parameterize" , "P" ] : if len ( args ) != 1 or kwargs : raise exceptions . ParamsError ( "P() should only pass in one argument!" ) from . import loader eval_value = loader . load_csv_file ( args [ 0 ] ) elif func_name in [ "environ" , "ENV" ] : if len ( args ) != 1 or kwargs : raise exceptions . ParamsError ( "ENV() should only pass in one argument!" ) eval_value = utils . get_os_environ ( args [ 0 ] ) else : func = get_mapping_function ( func_name , functions_mapping ) eval_value = func ( * args , * * kwargs ) func_content = "${" + func_content + "}" if func_content == content : # content is a function, e.g. "${add_one(3)}" content = eval_value else : # content contains one or many functions, e.g. "abc${add_one(3)}def" content = content . replace ( func_content , str ( eval_value ) , 1 ) return content