#NEWLINE# def match_spec( element , specification ) : #NEWLINE# #INDENT# '\n    Matches the group.label specification of the supplied\n    element against the supplied specification dictionary\n    returning the value of the best match.\n    ' #NEWLINE# match_tuple = ( ) #NEWLINE# match = specification . get ( ( ) , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) #NEWLINE# for spec in [ type ( element ) . __name__ , group_sanitizer ( match_tuple . group , escape = False ) , label_sanitizer ( element . label , escape = False ) ] : #NEWLINE# #INDENT# match_tuple += ( spec , ) #NEWLINE# if ( match_tuple in specification ) : #NEWLINE# #INDENT# match = specification [ match_tuple ] #NEWLINE# #UNINDENT# #UNINDENT# return match