<s> import re <EOL> import warnings <EOL> from django . conf import settings <EOL> from django . core . exceptions import ImproperlyConfigured <EOL> from django . utils . importlib import import_module <EOL> def _setting_to_instance ( setting ) : <EOL> if isinstance ( setting , basestring ) : <EOL> try : <EOL> parser = import_module ( setting ) <EOL> except ImportError : <EOL> try : <EOL> mpath , cname = setting . rsplit ( '<STR_LIT:.>' , <NUM_LIT:1> ) <EOL> except ValueError : <EOL> raise ImproperlyConfigured ( '<STR_LIT>' <EOL> '<STR_LIT>' % setting ) <EOL> module = import_module ( mpath ) <EOL> klass = getattr ( module , cname ) <EOL> parser = klass ( ) <EOL> return parser <EOL> if isinstance ( setting , type ) : <EOL> return setting ( ) <EOL> return setting <EOL> def get_parser ( ) : <EOL> setting = getattr ( settings , '<STR_LIT>' , '<STR_LIT>' ) <EOL> return _setting_to_instance ( setting ) <EOL> def get_auth_backend ( ) : <EOL> if hasattr ( settings , '<STR_LIT>' ) : <EOL> warnings . warn ( '<STR_LIT>' <EOL> '<STR_LIT>' , DeprecationWarning ) <EOL> setting = getattr ( settings , '<STR_LIT>' , <EOL> '<STR_LIT>' ) <EOL> return _setting_to_instance ( setting ) <EOL> def spaces_as_underscores ( ) : <EOL> return getattr ( settings , '<STR_LIT>' , True ) <EOL> def urlize_title ( title ) : <EOL> if spaces_as_underscores ( ) : <EOL> return re . sub ( r'<STR_LIT>' , '<STR_LIT:_>' , title ) <EOL> return title <EOL> def deurlize_title ( title ) : <EOL> if spaces_as_underscores ( ) : <EOL> return re . sub ( r'<STR_LIT>' , '<STR_LIT:U+0020>' , title ) <EOL> return title <EOL> def anchorize ( txt ) : <EOL> return re . compile ( r'<STR_LIT>' , re . UNICODE ) . sub ( '<STR_LIT:_>' , txt ) . strip ( '<STR_LIT:_>' ) <EOL> def get_templating_backend ( ) : <EOL> setting = getattr ( settings , '<STR_LIT>' , '<STR_LIT>' ) <EOL> return _setting_to_instance ( setting ) </s>
