<s> from django . core . urlresolvers import RegexURLPattern , Resolver404 , get_resolver <EOL> __all__ = ( '<STR_LIT>' , ) <EOL> def _dispatch ( pattern , path ) : <EOL> if isinstance ( pattern , RegexURLPattern ) : <EOL> return _pattern_resolve_to_name ( pattern , path ) <EOL> else : <EOL> return _resolver_resolve_to_name ( pattern , path ) <EOL> def _pattern_resolve_to_name ( self , path ) : <EOL> match = self . regex . search ( path ) <EOL> if match : <EOL> name = '<STR_LIT>' <EOL> if self . name : <EOL> name = self . name <EOL> elif hasattr ( self , '<STR_LIT>' ) : <EOL> name = self . _callback_str <EOL> else : <EOL> name = "<STR_LIT>" % ( self . callback . __module__ , self . callback . func_name ) <EOL> return name <EOL> def _resolver_resolve_to_name ( self , path ) : <EOL> tried = [ ] <EOL> match = self . regex . search ( path ) <EOL> if match : <EOL> new_path = path [ match . end ( ) : ] <EOL> for pattern in self . url_patterns : <EOL> try : <EOL> name = _dispatch ( pattern , new_path ) <EOL> except Resolver404 , e : <EOL> tried . extend ( [ ( pattern . regex . pattern + '<STR_LIT:U+0020>' + t ) for t in e . args [ <NUM_LIT:0> ] [ '<STR_LIT>' ] ] ) <EOL> else : <EOL> if name : <EOL> return name <EOL> tried . append ( pattern . regex . pattern ) <EOL> raise Resolver404 , { '<STR_LIT>' : tried , '<STR_LIT:path>' : new_path } <EOL> def resolve_to_name ( path , urlconf = None ) : <EOL> r = get_resolver ( urlconf ) <EOL> return _dispatch ( r , path ) </s>
