#NEWLINE# def _parse( self , challenge ) : #NEWLINE# #INDENT# '\n        Parses the server challenge.\n\n        Splits the challenge into a dictionary of directives with values.\n\n        @return: challenge directives and their values.\n        @rtype: L{dict} of L{str} to L{str}.\n        ' #NEWLINE# s = challenge #NEWLINE# paramDict = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# cur = 0 #NEWLINE# remainingParams = True #NEWLINE# while remainingParams : #NEWLINE# #INDENT# middle = s . index ( '=' , cur ) #NEWLINE# name = s [ cur : middle ] . lstrip ( ) #NEWLINE# middle += 1 #NEWLINE# if ( s [ middle ] == '"' ) : #NEWLINE# #INDENT# middle += 1 #NEWLINE# end = s . index ( '"' , middle ) #NEWLINE# value = s [ middle : end ] #NEWLINE# cur = ( s . find ( ',' , value ) + 1 ) #NEWLINE# if ( cur == 0 ) : #NEWLINE# #INDENT# remainingParams = False #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# end = s . find ( ',' , middle ) #NEWLINE# if ( end == ( - 1 ) ) : #NEWLINE# #INDENT# value = s [ middle : ] . rstrip ( ) #NEWLINE# remainingParams = False #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# value = s [ middle : end ] . rstrip ( ) #NEWLINE# #UNINDENT# cur = ( end + 1 ) #NEWLINE# #UNINDENT# paramDict [ name ] = value #NEWLINE# #UNINDENT# for param in ( 'qop' , 'cipher' ) : #NEWLINE# #INDENT# if ( param in paramDict ) : #NEWLINE# #INDENT# paramDict [ param ] = paramDict [ param ] . split ( ',' ) #NEWLINE# #UNINDENT# #UNINDENT# return paramDict