(content, variables_mapping=None, functions_mapping=None, raise_if_variable_not_found=True)
return content
parse content with variables mapping

    Args:
        content (str/dict/list/numeric/bool/type): content to be parsed
        variables_mapping (dict): variables mapping.
        functions_mapping (dict): functions mapping.
        raise_if_variable_not_found (bool): if set False, exception will not raise when VariableNotFound occurred.

    Returns:
        parsed content.

    Examples:
        >>> content = {
                'request': {
                    'url': '/api/users/$uid',
                    'headers': {'token': '$token'}
                }
            }
        >>> variables_mapping = {"uid": 1000, "token": "abcdef"}
        >>> parse_data(content, variables_mapping)
            {
                'request': {
                    'url': '/api/users/1000',
                    'headers': {'token': 'abcdef'}
                }
            }
parse content with variables mapping
parse content with variables mapping
def parse_data(content, variables_mapping=None, functions_mapping=None, raise_if_variable_not_found=True):
    """ parse content with variables mapping

    Args:
        content (str/dict/list/numeric/bool/type): content to be parsed
        variables_mapping (dict): variables mapping.
        functions_mapping (dict): functions mapping.
        raise_if_variable_not_found (bool): if set False, exception will not raise when VariableNotFound occurred.

    Returns:
        parsed content.

    Examples:
        >>> content = {
                'request': {
                    'url': '/api/users/$uid',
                    'headers': {'token': '$token'}
                }
            }
        >>> variables_mapping = {"uid": 1000, "token": "abcdef"}
        >>> parse_data(content, variables_mapping)
            {
                'request': {
                    'url': '/api/users/1000',
                    'headers': {'token': 'abcdef'}
                }
            }

    """
    # TODO: refactor type check
    if content is None or isinstance(content, (numeric_types, bool, type)):
        return content

    if isinstance(content, (list, set, tuple)):
        return [
            parse_data(
                item,
                variables_mapping,
                functions_mapping,
                raise_if_variable_not_found
            )
            for item in content
        ]

    if isinstance(content, dict):
        parsed_content = {}
        for key, value in content.items():
            parsed_key = parse_data(
                key,
                variables_mapping,
                functions_mapping,
                raise_if_variable_not_found
            )
            parsed_value = parse_data(
                value,
                variables_mapping,
                functions_mapping,
                raise_if_variable_not_found
            )
            parsed_content[parsed_key] = parsed_value

        return parsed_content

    if isinstance(content, basestring):
        # content is in string format here
        variables_mapping = utils.ensure_mapping_format(variables_mapping or {})
        functions_mapping = functions_mapping or {}
        content = content.strip()

        try:
            # replace functions with evaluated value
            # Notice: parse_string_functions must be called before parse_string_variables
            content = parse_string_functions(
                content,
                variables_mapping,
                functions_mapping
            )
            # replace variables with binding value
            content = parse_string_variables(
                content,
                variables_mapping,
                functions_mapping
            )
        except exceptions.VariableNotFound:
            if raise_if_variable_not_found:
                raise

    return content
def parse_data ( content , variables_mapping = None , functions_mapping = None , raise_if_variable_not_found = True ) : # TODO: refactor type check if content is None or isinstance ( content , ( numeric_types , bool , type ) ) : return content if isinstance ( content , ( list , set , tuple ) ) : return [ parse_data ( item , variables_mapping , functions_mapping , raise_if_variable_not_found ) for item in content ] if isinstance ( content , dict ) : parsed_content = { } for key , value in content . items ( ) : parsed_key = parse_data ( key , variables_mapping , functions_mapping , raise_if_variable_not_found ) parsed_value = parse_data ( value , variables_mapping , functions_mapping , raise_if_variable_not_found ) parsed_content [ parsed_key ] = parsed_value return parsed_content if isinstance ( content , basestring ) : # content is in string format here variables_mapping = utils . ensure_mapping_format ( variables_mapping or { } ) functions_mapping = functions_mapping or { } content = content . strip ( ) try : # replace functions with evaluated value # Notice: parse_string_functions must be called before parse_string_variables content = parse_string_functions ( content , variables_mapping , functions_mapping ) # replace variables with binding value content = parse_string_variables ( content , variables_mapping , functions_mapping ) except exceptions . VariableNotFound : if raise_if_variable_not_found : raise return content