#NEWLINE# def urlmatch( scheme = None , netloc = None , path = None , method = None , query = None ) : #NEWLINE# #INDENT# def decorator( func ) : #NEWLINE# #INDENT# @ wraps ( func ) #NEWLINE# def inner( self_or_url , url_or_request , * args , **kwargs ) : #NEWLINE# #INDENT# if isinstance ( self_or_url , urlparse . SplitResult ) : #NEWLINE# #INDENT# url = self_or_url #NEWLINE# request = url_or_request #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# url = url_or_request #NEWLINE# request = args [ 0 ] #NEWLINE# #UNINDENT# if ( ( scheme is not None ) and ( scheme != url . scheme ) ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# if ( ( netloc is not None ) and ( not re . match ( netloc , url . netloc ) ) ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# if ( ( path is not None ) and ( not re . match ( path , url . path ) ) ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# if ( ( query is not None ) and ( not re . match ( query , url . query ) ) ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# if ( ( method is not None ) and ( method . upper ( ) != request . method ) ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# return func ( self_or_url , url_or_request , * args , ** kwargs ) #NEWLINE# #UNINDENT# return inner #NEWLINE# #UNINDENT# return query