#NEWLINE# def parse_structured_sms_named_args( args , action , verified_number = None ) : #NEWLINE# #INDENT# '\n    Returns a dictionary of {xpath: answer}\n    ' #NEWLINE# xpath_answer = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for answer in args : #NEWLINE# #INDENT# answer = answer . strip ( ) #NEWLINE# answer_upper = answer . upper ( ) #NEWLINE# if ( action . named_args_separator is not None ) : #NEWLINE# #INDENT# answer_parts = answer . partition ( action . named_args_separator ) #NEWLINE# if ( answer_parts [ 1 ] != action . named_args_separator ) : #NEWLINE# #INDENT# error_msg = get_message ( MSG_EXPECTED_NAMED_ARGS_SEPARATOR , verified_number , ( action . named_args_separator , ) ) #NEWLINE# raise StructuredSMSException ( response_text = error_msg ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# arg_name = answer_parts [ 0 ] . upper ( ) . strip ( ) #NEWLINE# xpath = action . named_args . get ( arg_name , None ) #NEWLINE# if ( xpath is not None ) : #NEWLINE# #INDENT# if ( xpath in xpath_answer ) : #NEWLINE# #INDENT# error_msg = get_message ( MSG_MULTIPLE_ANSWERS_FOUND , verified_number , ( arg_name , ) ) #NEWLINE# raise StructuredSMSException ( response_text = error_msg ) #NEWLINE# #UNINDENT# xpath_answer [ xpath ] = answer_parts [ 2 ] . strip ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# matches = 0 #NEWLINE# for ( k , v ) in action . named_args . items ( ) : #NEWLINE# #INDENT# if answer_upper . startswith ( k ) : #NEWLINE# #INDENT# matches += 1 #NEWLINE# if ( matches > 1 ) : #NEWLINE# #INDENT# error_msg = get_message ( MSG_MULTIPLE_QUESTIONS_MATCH , verified_number , ( answer , ) ) #NEWLINE# raise StructuredSMSException ( response_text = error_msg ) #NEWLINE# #UNINDENT# if ( v in xpath_answer ) : #NEWLINE# #INDENT# error_msg = get_message ( MSG_MULTIPLE_ANSWERS_FOUND , verified_number , ( k , ) ) #NEWLINE# raise StructuredSMSException ( response_text = error_msg ) #NEWLINE# #UNINDENT# xpath_answer [ v ] = answer [ len ( k ) : ] . strip ( ) #NEWLINE# #UNINDENT# #UNINDENT# if ( matches == 0 ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return xpath_answer