#NEWLINE# def __call__( self , path , **data ) : #NEWLINE# #INDENT# ' Calls the handler function for the given URL path.\n            If no handler is found, raises a RouteError.\n            If a base handler is found (e.g., "/api" for "/api/1/en"),\n            calls the handler with arguments (e.g., handler("1", "en")).\n        ' #NEWLINE# if ( not isinstance ( path , tuple ) ) : #NEWLINE# #INDENT# path = path . strip ( '/' ) . split ( '/' ) #NEWLINE# #UNINDENT# n = len ( path ) #NEWLINE# for i in xrange ( ( data + 1 ) ) : #NEWLINE# #INDENT# p0 = ( '/' + '/' . join ( path [ : ( n - i ) ] ) ) #NEWLINE# p0 = p0 . lower ( ) #NEWLINE# p1 = path [ ( n - i ) : ] #NEWLINE# if ( p0 in self ) : #NEWLINE# #INDENT# ( handler , ( args , kwargs ) ) = self [ p0 ] #NEWLINE# i = len ( p1 ) #NEWLINE# j = ( len ( args ) if ( args is not True ) else i ) #NEWLINE# if ( ( i == 0 ) and ( j == 1 ) ) : #NEWLINE# #INDENT# p1 = ( None , ) #NEWLINE# i = j #NEWLINE# #UNINDENT# if ( i != j ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# if ( not callable ( handler ) ) : #NEWLINE# #INDENT# return handler #NEWLINE# #UNINDENT# if ( not kwargs ) : #NEWLINE# #INDENT# return handler ( * p1 ) #NEWLINE# #UNINDENT# if ( kwargs is True ) : #NEWLINE# #INDENT# return handler ( * p1 , ** data ) #NEWLINE# #UNINDENT# return handler ( * p1 , ** dict ( ( ( k , v ) for ( k , v ) in data . items ( ) if ( k in kwargs ) ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# raise RouteError