<s> """<STR_LIT>""" <EOL> from django . conf import settings <EOL> from django . template import TemplateDoesNotExist <EOL> from django . template . loader import get_template <EOL> from django . utils import six <EOL> def track_view_name ( request , view_func ) : <EOL> if request . META . get ( '<STR_LIT>' ) in settings . INTERNAL_IPS or ( request . user . is_active and request . user . is_staff ) : <EOL> view_name = "<STR_LIT>" . format ( view_func . __module__ , get_view_name ( view_func ) ) <EOL> request . _xview = view_name <EOL> return view_name <EOL> def get_view_name ( view_func ) : <EOL> if not hasattr ( view_func , '<STR_LIT>' ) : <EOL> return view_func . __class__ . __name__ <EOL> else : <EOL> return view_func . __name__ <EOL> def get_used_view_name ( request ) : <EOL> return getattr ( request , '<STR_LIT>' , None ) <EOL> def get_used_template ( response ) : <EOL> """<STR_LIT>""" <EOL> if not hasattr ( response , '<STR_LIT>' ) : <EOL> return None , None <EOL> template = response . template_name <EOL> if template is None : <EOL> return None , None <EOL> if isinstance ( template , ( list , tuple ) ) : <EOL> if len ( template ) == <NUM_LIT:1> : <EOL> return template [ <NUM_LIT:0> ] , None <EOL> else : <EOL> used_name = _get_used_template_name ( template ) <EOL> return used_name , template <EOL> elif isinstance ( template , six . string_types ) : <EOL> return template , None <EOL> else : <EOL> filename = _get_template_filename ( template ) <EOL> template_name = '<STR_LIT>' . format ( filename ) if filename else '<STR_LIT>' <EOL> return template_name , None <EOL> def _get_used_template_name ( template_name_list ) : <EOL> """<STR_LIT>""" <EOL> for template_name in template_name_list : <EOL> try : <EOL> get_template ( template_name ) <EOL> return template_name <EOL> except TemplateDoesNotExist : <EOL> continue <EOL> def _get_template_filename ( template ) : <EOL> try : <EOL> return template . nodelist [ <NUM_LIT:0> ] . origin [ <NUM_LIT:0> ] . name <EOL> except ( AttributeError , IndexError ) : <EOL> return None </s>
