<s> from django . core . urlresolvers import ( RegexURLPattern , <EOL> RegexURLResolver , LocaleRegexURLResolver ) <EOL> from django . core . exceptions import ImproperlyConfigured <EOL> from django . utils . importlib import import_module <EOL> from django . utils import six <EOL> __all__ = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:url>' ] <EOL> handler403 = '<STR_LIT>' <EOL> handler404 = '<STR_LIT>' <EOL> handler500 = '<STR_LIT>' <EOL> def include ( arg , namespace = None , app_name = None ) : <EOL> if isinstance ( arg , tuple ) : <EOL> if namespace : <EOL> raise ImproperlyConfigured ( '<STR_LIT>' ) <EOL> urlconf_module , app_name , namespace = arg <EOL> else : <EOL> urlconf_module = arg <EOL> if isinstance ( urlconf_module , six . string_types ) : <EOL> urlconf_module = import_module ( urlconf_module ) <EOL> patterns = getattr ( urlconf_module , '<STR_LIT>' , urlconf_module ) <EOL> if isinstance ( patterns , ( list , tuple ) ) : <EOL> for url_pattern in patterns : <EOL> if isinstance ( url_pattern , LocaleRegexURLResolver ) : <EOL> raise ImproperlyConfigured ( <EOL> '<STR_LIT>' ) <EOL> return ( urlconf_module , app_name , namespace ) <EOL> def patterns ( prefix , * args ) : <EOL> pattern_list = [ ] <EOL> for t in args : <EOL> if isinstance ( t , ( list , tuple ) ) : <EOL> t = url ( prefix = prefix , * t ) <EOL> elif isinstance ( t , RegexURLPattern ) : <EOL> t . add_prefix ( prefix ) <EOL> pattern_list . append ( t ) <EOL> return pattern_list <EOL> def url ( regex , view , kwargs = None , name = None , prefix = '<STR_LIT>' ) : <EOL> if isinstance ( view , ( list , tuple ) ) : <EOL> urlconf_module , app_name , namespace = view <EOL> return RegexURLResolver ( regex , urlconf_module , kwargs , app_name = app_name , namespace = namespace ) <EOL> else : <EOL> if isinstance ( view , six . string_types ) : <EOL> if not view : <EOL> raise ImproperlyConfigured ( '<STR_LIT>' % regex ) <EOL> if prefix : <EOL> view = prefix + '<STR_LIT:.>' + view <EOL> return RegexURLPattern ( regex , view , kwargs , name ) </s>
