<s> import re <EOL> from django . conf import settings <EOL> try : <EOL> from django . conf . urls . defaults import url as ourl <EOL> except ImportError : <EOL> from django . conf . urls import url as ourl <EOL> REGEXERS = { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT:int>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT:username>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> } <EOL> REGEXERS . update ( getattr ( settings , "<STR_LIT>" , { } ) ) <EOL> _R = re . compile ( "<STR_LIT>" ) <EOL> def _regex_substituter ( m ) : <EOL> """<STR_LIT>""" <EOL> name = m . groups ( ) [ <NUM_LIT:0> ] <EOL> if "<STR_LIT::>" not in name : <EOL> name = "<STR_LIT>" % name <EOL> t , n = name . split ( "<STR_LIT::>" ) <EOL> return "<STR_LIT>" % ( n , REGEXERS [ t ] ) <EOL> def translate_regex ( regex ) : <EOL> """<STR_LIT>""" <EOL> return regex if not regex . startswith ( "<STR_LIT:/>" ) else "<STR_LIT>" % _R . sub ( <EOL> _regex_substituter , regex ) [ <NUM_LIT:1> : ] <EOL> def surl ( regex , * args , ** kw ) : <EOL> """<STR_LIT>""" <EOL> return ourl ( translate_regex ( regex ) , * args , ** kw ) <EOL> url = surl </s>
