(args, action, verified_number=None)
return xpath_answer
Returns a dictionary of {xpath: answer}
Returns a dictionary of {xpath: answer}
Returns a dictionary of { xpath : answer }
def parse_structured_sms_named_args(args, action, verified_number=None):
    """
    Returns a dictionary of {xpath: answer}
    """
    xpath_answer = {}
    for answer in args:
        answer = answer.strip()
        answer_upper = answer.upper()
        if action.named_args_separator is not None:
            # A separator is used for naming arguments; for example, the "="
            # in "register name=joe age=25"
            answer_parts = answer.partition(action.named_args_separator)
            if answer_parts[1] != action.named_args_separator:
                error_msg = get_message(MSG_EXPECTED_NAMED_ARGS_SEPARATOR,
                    verified_number, (action.named_args_separator,))
                raise StructuredSMSException(response_text=error_msg)
            else:
                arg_name = answer_parts[0].upper().strip()
                xpath = action.named_args.get(arg_name, None)
                if xpath is not None:
                    if xpath in xpath_answer:
                        error_msg = get_message(MSG_MULTIPLE_ANSWERS_FOUND,
                            verified_number,
                            (arg_name,))
                        raise StructuredSMSException(response_text=error_msg)

                    xpath_answer[xpath] = answer_parts[2].strip()
                else:
                    # Ignore unexpected named arguments
                    pass
        else:
            # No separator is used for naming arguments
            # for example, "update a100 b34 c5"
            matches = 0
            for k, v in action.named_args.items():
                if answer_upper.startswith(k):
                    matches += 1
                    if matches > 1:
                        error_msg = get_message(MSG_MULTIPLE_QUESTIONS_MATCH,
                            verified_number,
                            (answer,))
                        raise StructuredSMSException(response_text=error_msg)

                    if v in xpath_answer:
                        error_msg = get_message(MSG_MULTIPLE_ANSWERS_FOUND,
                            verified_number,
                            (k,))
                        raise StructuredSMSException(response_text=error_msg)

                    xpath_answer[v] = answer[len(k):].strip()

            if matches == 0:
                # Ignore unexpected named arguments
                pass
    return xpath_answer
def parse_structured_sms_named_args ( args , action , verified_number = None ) : xpath_answer = { } for answer in args : answer = answer . strip ( ) answer_upper = answer . upper ( ) if action . named_args_separator is not None : # A separator is used for naming arguments; for example, the "=" # in "register name=joe age=25" answer_parts = answer . partition ( action . named_args_separator ) if answer_parts [ 1 ] != action . named_args_separator : error_msg = get_message ( MSG_EXPECTED_NAMED_ARGS_SEPARATOR , verified_number , ( action . named_args_separator , ) ) raise StructuredSMSException ( response_text = error_msg ) else : arg_name = answer_parts [ 0 ] . upper ( ) . strip ( ) xpath = action . named_args . get ( arg_name , None ) if xpath is not None : if xpath in xpath_answer : error_msg = get_message ( MSG_MULTIPLE_ANSWERS_FOUND , verified_number , ( arg_name , ) ) raise StructuredSMSException ( response_text = error_msg ) xpath_answer [ xpath ] = answer_parts [ 2 ] . strip ( ) else : # Ignore unexpected named arguments pass else : # No separator is used for naming arguments # for example, "update a100 b34 c5" matches = 0 for k , v in action . named_args . items ( ) : if answer_upper . startswith ( k ) : matches += 1 if matches > 1 : error_msg = get_message ( MSG_MULTIPLE_QUESTIONS_MATCH , verified_number , ( answer , ) ) raise StructuredSMSException ( response_text = error_msg ) if v in xpath_answer : error_msg = get_message ( MSG_MULTIPLE_ANSWERS_FOUND , verified_number , ( k , ) ) raise StructuredSMSException ( response_text = error_msg ) xpath_answer [ v ] = answer [ len ( k ) : ] . strip ( ) if matches == 0 : # Ignore unexpected named arguments pass return xpath_answer