<s> import operator <EOL> import warnings <EOL> from django import template <EOL> from django . template . defaultfilters import stringfilter <EOL> from django . utils import six <EOL> from django . utils . html import escape , format_html <EOL> register = template . Library ( ) <EOL> @ register . filter <EOL> @ stringfilter <EOL> def trim ( value , num ) : <EOL> return value [ : num ] <EOL> @ register . filter <EOL> def noop ( value , param = None ) : <EOL> """<STR_LIT>""" <EOL> return value <EOL> @ register . simple_tag ( takes_context = True ) <EOL> def context_stack_length ( context ) : <EOL> return len ( context . dicts ) <EOL> @ register . simple_tag <EOL> def no_params ( ) : <EOL> """<STR_LIT>""" <EOL> return "<STR_LIT>" <EOL> no_params . anything = "<STR_LIT>" <EOL> @ register . simple_tag <EOL> def one_param ( arg ) : <EOL> """<STR_LIT>""" <EOL> return "<STR_LIT>" % arg <EOL> one_param . anything = "<STR_LIT>" <EOL> @ register . simple_tag ( takes_context = False ) <EOL> def explicit_no_context ( arg ) : <EOL> """<STR_LIT>""" <EOL> return "<STR_LIT>" % arg <EOL> explicit_no_context . anything = "<STR_LIT>" <EOL> @ register . simple_tag ( takes_context = True ) <EOL> def no_params_with_context ( context ) : <EOL> """<STR_LIT>""" <EOL> return "<STR_LIT>" % context [ '<STR_LIT:value>' ] <EOL> no_params_with_context . anything = "<STR_LIT>" <EOL> @ register . simple_tag ( takes_context = True ) <EOL> def params_and_context ( context , arg ) : <EOL> """<STR_LIT>""" <EOL> return "<STR_LIT>" % ( context [ '<STR_LIT:value>' ] , arg ) <EOL> params_and_context . anything = "<STR_LIT>" <EOL> @ register . simple_tag <EOL> def simple_two_params ( one , two ) : <EOL> """<STR_LIT>""" <EOL> return "<STR_LIT>" % ( one , two ) <EOL> simple_two_params . anything = "<STR_LIT>" <EOL> @ register . simple_tag <EOL> def simple_one_default ( one , two = '<STR_LIT>' ) : <EOL> """<STR_LIT>""" <EOL> return "<STR_LIT>" % ( one , two ) <EOL> simple_one_default . anything = "<STR_LIT>" <EOL> @ register . simple_tag <EOL> def simple_unlimited_args ( one , two = '<STR_LIT>' , * args ) : <EOL> """<STR_LIT>""" <EOL> return "<STR_LIT>" % ( <EOL> '<STR_LIT:U+002CU+0020>' . join ( six . text_type ( arg ) for arg in [ one , two ] + list ( args ) ) <EOL> ) <EOL> simple_unlimited_args . anything = "<STR_LIT>" <EOL> @ register . simple_tag <EOL> def simple_only_unlimited_args ( * args ) : <EOL> """<STR_LIT>""" <EOL> return "<STR_LIT>" % '<STR_LIT:U+002CU+0020>' . join ( six . text_type ( arg ) for arg in args ) <EOL> simple_only_unlimited_args . anything = "<STR_LIT>" <EOL> @ register . simple_tag <EOL> def simple_unlimited_args_kwargs ( one , two = '<STR_LIT>' , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> sorted_kwarg = sorted ( six . iteritems ( kwargs ) , key = operator . itemgetter ( <NUM_LIT:0> ) ) <EOL> return "<STR_LIT>" % ( <EOL> '<STR_LIT:U+002CU+0020>' . join ( six . text_type ( arg ) for arg in [ one , two ] + list ( args ) ) , <EOL> '<STR_LIT:U+002CU+0020>' . join ( '<STR_LIT>' % ( k , v ) for ( k , v ) in sorted_kwarg ) <EOL> ) <EOL> simple_unlimited_args_kwargs . anything = "<STR_LIT>" <EOL> @ register . simple_tag ( takes_context = True ) <EOL> def simple_tag_without_context_parameter ( arg ) : <EOL> """<STR_LIT>""" <EOL> return "<STR_LIT>" <EOL> simple_tag_without_context_parameter . anything = "<STR_LIT>" <EOL> @ register . simple_tag ( takes_context = True ) <EOL> def escape_naive ( context ) : <EOL> """<STR_LIT>""" <EOL> return "<STR_LIT>" . format ( context [ '<STR_LIT:name>' ] ) <EOL> @ register . simple_tag ( takes_context = True ) <EOL> def escape_explicit ( context ) : <EOL> """<STR_LIT>""" <EOL> return escape ( "<STR_LIT>" . format ( context [ '<STR_LIT:name>' ] ) ) <EOL> @ register . simple_tag ( takes_context = True ) <EOL> def escape_format_html ( context ) : <EOL> """<STR_LIT>""" <EOL> return format_html ( "<STR_LIT>" , context [ '<STR_LIT:name>' ] ) <EOL> @ register . simple_tag ( takes_context = True ) <EOL> def current_app ( context ) : <EOL> return "<STR_LIT:%s>" % context . current_app <EOL> @ register . simple_tag ( takes_context = True ) <EOL> def use_l10n ( context ) : <EOL> return "<STR_LIT:%s>" % context . use_l10n <EOL> @ register . simple_tag ( name = '<STR_LIT>' ) <EOL> def minustwo_overridden_name ( value ) : <EOL> return value - <NUM_LIT:2> <EOL> register . simple_tag ( lambda x : x - <NUM_LIT:1> , name = '<STR_LIT>' ) <EOL> with warnings . catch_warnings ( ) : <EOL> warnings . simplefilter ( '<STR_LIT:ignore>' ) <EOL> @ register . assignment_tag <EOL> def assignment_no_params ( ) : <EOL> """<STR_LIT>""" <EOL> return "<STR_LIT>" <EOL> assignment_no_params . anything = "<STR_LIT>" <EOL> @ register . assignment_tag ( takes_context = True ) <EOL> def assignment_tag_without_context_parameter ( arg ) : <EOL> """<STR_LIT>""" <EOL> return "<STR_LIT>" <EOL> assignment_tag_without_context_parameter . anything = "<STR_LIT>" </s>
