#NEWLINE# def match_arg( s , ip , port ) : #NEWLINE# #INDENT# m = re . match ( '^\\[([a-fA-F0-9:]+)\\]:(\\d+)$' , s ) #NEWLINE# m = ( m or re . match ( '^([\\d\\.]+):(\\d+)$' , s ) ) #NEWLINE# if m : #NEWLINE# #INDENT# return ( ip_string_eq ( m . group ( 1 ) , ip ) and ( int ( m . group ( 2 ) ) == port ) ) #NEWLINE# #UNINDENT# m = re . match ( '^\\[?([a-fA-F0-9:]+)\\]?$' , s ) #NEWLINE# m = ( m or re . match ( '^([\\d\\.]+)$' , s ) ) #NEWLINE# if port : #NEWLINE# #INDENT# return ip_string_eq ( m . group ( 1 ) , ip ) #NEWLINE# #UNINDENT# raise Exception ( ( 'malformed address: ' + s ) )