<s> """<STR_LIT>""" <EOL> from __future__ import unicode_literals <EOL> from pprint import pprint <EOL> from django . conf import settings <EOL> from django import template <EOL> import socket <EOL> from template_debug . utils import get_variables , get_details , get_attributes <EOL> register = template . Library ( ) <EOL> def require_template_debug ( f ) : <EOL> """<STR_LIT>""" <EOL> def _ ( * args , ** kwargs ) : <EOL> TEMPLATE_DEBUG = getattr ( settings , '<STR_LIT>' , False ) <EOL> return f ( * args , ** kwargs ) if TEMPLATE_DEBUG else '<STR_LIT>' <EOL> return _ <EOL> def _display_details ( var_data ) : <EOL> """<STR_LIT>""" <EOL> meta_keys = ( key for key in list ( var_data . keys ( ) ) <EOL> if key . startswith ( '<STR_LIT>' ) ) <EOL> for key in meta_keys : <EOL> display_key = key [ <NUM_LIT:5> : ] . capitalize ( ) <EOL> pprint ( '<STR_LIT>' . format ( display_key , var_data . pop ( key ) ) ) <EOL> pprint ( var_data ) <EOL> @ require_template_debug <EOL> @ register . simple_tag ( takes_context = True ) <EOL> def variables ( context ) : <EOL> """<STR_LIT>""" <EOL> availables = get_variables ( context ) <EOL> pprint ( availables ) <EOL> return availables <EOL> @ require_template_debug <EOL> @ register . simple_tag <EOL> def attributes ( var ) : <EOL> """<STR_LIT>""" <EOL> attrs = get_attributes ( var ) <EOL> pprint ( attrs ) <EOL> return attrs <EOL> @ require_template_debug <EOL> @ register . simple_tag <EOL> def details ( var ) : <EOL> """<STR_LIT>""" <EOL> var_details = get_details ( var ) <EOL> _display_details ( var_details ) <EOL> return var_details <EOL> @ require_template_debug <EOL> @ register . simple_tag ( takes_context = True ) <EOL> def set_trace ( context ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> import ipdb as pdb <EOL> except ImportError : <EOL> import pdb <EOL> print ( "<STR_LIT>" ) <EOL> print ( "<STR_LIT>" ) <EOL> render = lambda s : template . Template ( s ) . render ( context ) <EOL> availables = get_variables ( context ) <EOL> pprint ( availables ) <EOL> print ( '<STR_LIT>' ) <EOL> print ( '<STR_LIT>' ) <EOL> print ( '<STR_LIT>' ) <EOL> for var in availables : <EOL> locals ( ) [ var ] = context [ var ] <EOL> pdb . set_trace ( ) <EOL> return '<STR_LIT>' <EOL> pdevd_not_available = False <EOL> @ require_template_debug <EOL> @ register . simple_tag ( takes_context = True ) <EOL> def pydevd ( context ) : <EOL> """<STR_LIT>""" <EOL> global pdevd_not_available <EOL> if pdevd_not_available : <EOL> return '<STR_LIT>' <EOL> try : <EOL> import pydevd <EOL> except ImportError : <EOL> pdevd_not_available = True <EOL> return '<STR_LIT>' <EOL> render = lambda s : template . Template ( s ) . render ( context ) <EOL> availables = get_variables ( context ) <EOL> for var in availables : <EOL> locals ( ) [ var ] = context [ var ] <EOL> try : <EOL> pydevd . settrace ( ) <EOL> except socket . error : <EOL> pdevd_not_available = True <EOL> return '<STR_LIT>' </s>
