<s> from django . core import urlresolvers <EOL> from django . utils . functional import Promise <EOL> def resolve_url ( to , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> from compat import six , force_text <EOL> if hasattr ( to , '<STR_LIT>' ) : <EOL> return to . get_absolute_url ( ) <EOL> if isinstance ( to , Promise ) : <EOL> to = force_text ( to ) <EOL> if isinstance ( to , six . string_types ) : <EOL> if any ( to . startswith ( path ) for path in ( '<STR_LIT>' , '<STR_LIT>' ) ) : <EOL> return to <EOL> try : <EOL> return urlresolvers . reverse ( to , args = args , kwargs = kwargs ) <EOL> except urlresolvers . NoReverseMatch : <EOL> if callable ( to ) : <EOL> raise <EOL> if '<STR_LIT:/>' not in to and '<STR_LIT:.>' not in to : <EOL> raise <EOL> return to </s>
