
    MȂiHB                         S SK Jr  S SKJr  S SKJr  S SKJrJr  S SK	J
r
  S SKJr  SSKJrJrJr  SS	KJr   " S
 S\5      r " S S5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      rS rS rg)    )Iterable)wraps)import_module)getfullargspecunwrap)conditional_escape)lazy_annotations   )NodeTemplatetoken_kwargs)TemplateSyntaxErrorc                       \ rS rSrSrg)InvalidTemplateLibrary    N)__name__
__module____qualname____firstlineno____static_attributes__r       HD:\sksbv-state-backend\venv\Lib\site-packages\django/template/library.pyr   r      s    r   r   c                   \    \ rS rSrSrS rSS jrS rSS jrS r	SS	 jr
SS
 jrSS jrSrg)Library   z
A class for registering template tags and filters. Compiled filter and
template tag functions are stored in the filters and tags attributes.
The filter, simple_tag, and inclusion_tag methods provide a convenient
way to register callables as tags.
c                      0 U l         0 U l        g Nfilterstags)selfs    r   __init__Library.__init__   s    	r   Nc                    ^ ^ Tc  Uc  T R                   $ Tb-  Uc*  [        T5      (       a  T R                  T5      $ UU 4S jnU$ Tb  Ub  UT R                  T'   U$ [        ST< SU< S35      e)Nc                 (   > TR                  TU 5      $ r   )tag)funcnamer"   s    r   decLibrary.tag.<locals>.dec'   s    88D$//r   z'Unsupported arguments to Library.tag: (, ))tag_functioncallabler!   
ValueError)r"   r)   compile_functionr*   s   ``  r   r'   Library.tag   s    <,4$$$"2":~~((..0 
"2">.DIIdO##)+ r   c                 6    XR                   UR                  '   U$ r   )r!   r   )r"   r(   s     r   r.   Library.tag_function5   s    #'		$-- r   c                 ^  ^ ^^ Tc  Uc	  UU 4S jnU$ Tb0  Uc-  [        T5      (       a  T R                  " T40 TD6$ UUU 4S jnU$ TbR  UbO  UT R                  T'   S H1  nUT;   d  M  TU   n[        X%U5        [        [	        U5      XV5        M3     TUl        U$ [        ST< SU< S35      e)zq
Register a callable as a template filter. Example:

@register.filter
def lower(value):
    return value.lower()
c                 *   > TR                   " U 40 TD6$ r   )filter_function)r(   flagsr"   s    r   r*   Library.filter.<locals>.decC   s    ++D:E::r   c                 ,   > TR                   " TU 40 TD6$ r   )filter)r(   r8   r)   r"   s    r   r*   r9   N   s    ;;tT;U;;r   )expects_localtimeis_safeneeds_autoescapez*Unsupported arguments to Library.filter: (r,   r-   )r/   r7   r    setattrr   _filter_namer0   )r"   r)   filter_funcr8   r*   attrvalues   `` `   r   r;   Library.filter9   s     <K/; J+"5~~++D:E::< 
+"9!,DLLL5=!$KEKu5 F;/= M (,K$& r   c                 >    U R                   " UR                  U40 UD6$ r   )r;   r   )r"   r(   r8   s      r   r7   Library.filter_functione   s    {{4==$8%88r   c                 h   ^ ^^ UU U4S jnUc  U$ [        U5      (       a  U" U5      $ [        S5      e)z
Register a callable as a compiled template tag. Example:

@register.simple_tag
def hello(*args, **kwargs):
    return 'world'
c           
        >^ ^^^^^^^	 [        5          [        [        T 5      5      u  mmm	mmmnS S S 5        T
=(       d    T R                  m[	        T 5      UU UUUUUUU	4	S j5       nTR                  TU5        T $ ! , (       d  f       NS= f)Nc                    >	 UR                  5       SS  nS n[        U5      S:  a  US   S:X  a
  US   nUS S n[        U UTTTTT	T
TT5
      u  pE[        TTXEU5      $ )Nr
      as)split_contentslen
parse_bits
SimpleNode)parsertokenbits
target_varargskwargsdefaultsr(   function_namekwonlykwonly_defaultsparamstakes_contextvarargsvarkws         r   compile_func5Library.simple_tag.<locals>.dec.<locals>.compile_func~   s    ++-ab1!
t9>d2h$&6!%bJ9D)#!!  "$tZPPr   r	   r   r   r   r   r'   )r(   _r`   rX   rY   rZ   r[   r\   r^   r_   r)   r"   r]   s   `  @@@@@@@r   r*   Library.simple_tag.<locals>.decq   s    !# #6$<0# $ !1DMMM4[Q Q Q( HH]L1KE $#s   A>>
Bz(Invalid arguments provided to simple_tagr/   r0   )r"   r(   r]   r)   r*   s   ` `` r   
simple_tagLibrary.simple_tagh   s4    #	J <Jd^^t9GHHr   c                 l   ^ ^^^ UUU U4S jnUc  U$ [        U5      (       a  U" U5      $ [        S5      e)z
Register a callable as a compiled block template tag. Example:

@register.simple_block_tag
def hello(content):
    return 'world'
c                 0  >^ ^^^^^^^	 [        5          [        [        T 5      5      u  mmm	mmmnS S S 5        T=(       d    T R                  mT
c  ST 3m
[	        T 5      UU
U UUUUUUU	4
S j5       nTR                  TU5        T $ ! , (       d  f       N\= f)Nendc                   >
 TR                  5       nT(       a+  [        U5      S:  a  US   S:X  a  US	 O2[        T< S35      eU(       a  US   S:X  a  US	 O[        ST S35      eUR                  5       SS  nS n[        U5      S:  a  US   S	:X  a
  US
   nUS S nU R	                  T	45      nU R                  5         [        U UUTTTTTTT5
      u  pg[        UT
TXgU5      $ )NrJ   r
   contentzv is decorated with takes_context=True so it must have a first argument of 'context' and a second argument of 'content'r   'z)' must have a first argument of 'content'rK   rL   rM   )copyrO   r   rN   parsedelete_first_tokenrP   SimpleBlockNode)rR   rS   
tag_paramsrT   rU   nodelistrV   rW   rX   end_namer(   rY   rZ   r[   r\   r]   r^   r_   s           r   r`   ;Library.simple_block_tag.<locals>.dec.<locals>.compile_func   s#   #[[]
 :!+
10J&qM1,/ 04 4 
  JqMY$>"1-M?*ST  ++-ab1!
t9>d2h$&6!%bJ9D!<<4))+)#!!  'dM4 r   rb   )r(   rc   r`   rX   rY   rZ   r[   r\   r^   r_   rt   r)   r"   r]   s   `  @@@@@@@r   r*   %Library.simple_block_tag.<locals>.dec   s    !# #6$<0# $ !1DMMM 04[+ + +Z HH]L1K} $#s   B
Bz.Invalid arguments provided to simple_block_tagre   )r"   r(   r]   r)   rt   r*   s   ` ``` r   simple_block_tagLibrary.simple_block_tag   s;    @	 @	D <Jd^^t9MNNr   c                     ^ ^^^ UUU U4S jnU$ )z
Register a callable as an inclusion tag:

@register.inclusion_tag('results.html')
def show_results(poll):
    choices = poll.choice_set.all()
    return {'choices': choices}
c                    >^ ^^^^^^^	 [        5          [        [        T 5      5      u  mmm	mmmnS S S 5        T=(       d    T R                  m[	        T 5      UU
U UUUUUUU	4
S j5       nTR                  TU5        T $ ! , (       d  f       NT= f)Nc                 t   >
 UR                  5       SS  n[        U UTTTTT	T
TT5
      u  p4[        TTUUT5      $ )Nr
   )rN   rP   InclusionNode)rR   rS   rT   rV   rW   rX   filenamer(   rY   rZ   r[   r\   r]   r^   r_   s        r   r`   8Library.inclusion_tag.<locals>.dec.<locals>.compile_func
  s`    ++-ab1)#!!  %! r   rb   )r(   rc   r`   rX   rY   rZ   r[   r\   r^   r_   r}   r)   r"   r]   s   `  @@@@@@@r   r*   "Library.inclusion_tag.<locals>.dec   s    !# #6$<0# $ !1DMMM4[  , HH]L1KI $#s   A??
Br   )r"   r}   r(   r]   r)   r*   s   `` `` r   inclusion_tagLibrary.inclusion_tag   s    %	 %	N 
r   r   )NN)NNN)NNNN)r   r   r   r   __doc__r#   r'   r.   r;   r7   rf   rw   r   r   r   r   r   r   r      s5    0*X95InROh1r   r   c                   $    \ rS rSrSrS rS rSrg)TagHelperNodei'  z
Base class for tag helper nodes such as SimpleNode and InclusionNode.
Manages the positional and keyword arguments to be passed to the decorated
function.
c                 4    Xl         X l        X0l        X@l        g r   )r(   r]   rV   rW   )r"   r(   r]   rV   rW   s        r   r#   TagHelperNode.__init__.  s    	*	r   c                    U R                    Vs/ sH  o"R                  U5      PM     nnU R                  (       a  U/UQnU R                  R	                  5        VVs0 sH  u  pEXER                  U5      _M     nnnX64$ s  snf s  snnf r   )rV   resolver]   rW   items)r"   contextvarresolved_argskvresolved_kwargss          r   get_resolved_arguments$TagHelperNode.get_resolved_arguments4  s}    9=C#W-C$5}5M=A[[=N=N=PQ=PTQ1ii00=PQ--	 D Rs   A?B)rV   r(   rW   r]   N)r   r   r   r   r   r#   r   r   r   r   r   r   r   '  s    .r   r   c                   2   ^  \ rS rSrSrU 4S jrS rSrU =r$ )rQ   i<  r   c                 2   > [         TU ]  XX45        XPl        g r   )superr#   rU   )r"   r(   r]   rV   rW   rU   	__class__s         r   r#   SimpleNode.__init__?  s    d;$r   c                     U R                  U5      u  p#U R                  " U0 UD6nU R                  b  XAU R                  '   gUR                  (       a  [	        U5      nU$ )N )r   r(   rU   
autoescaper   )r"   r   r   r   outputs        r   renderSimpleNode.renderC  sY    )-)D)DW)M&M=_=??&'-DOO$'/Fr   )rU   )	r   r   r   r   child_nodelistsr#   r   r   __classcell__r   s   @r   rQ   rQ   <  s    O% r   rQ   c                   4   ^  \ rS rSrU 4S jrU 4S jrSrU =r$ )rq   iN  c                 2   > [         TU ]  " U0 UD6  Xl        g r   )r   r#   rs   )r"   rs   rV   rW   r   s       r   r#   SimpleBlockNode.__init__O  s    $)&) r   c                    > [         TU ]  U5      u  p#UR                  U R                  (       a  SOSU R                  R                  U5      5        X#4$ )Nr
   r   )r   r   insertr]   rs   r   )r"   r   r   r   r   s       r   r   &SimpleBlockNode.get_resolved_argumentsS  sN    ).)G)P& 	##ADMM,@,@,I	
 --r   )rs   )r   r   r   r   r#   r   r   r   r   s   @r   rq   rq   N  s    !	. 	.r   rq   c                   .   ^  \ rS rSrU 4S jrS rSrU =r$ )r|   i_  c                 2   > [         TU ]  XX45        XPl        g r   )r   r#   r}   )r"   r(   r]   rV   rW   r}   r   s         r   r#   InclusionNode.__init__`  s    d; r   c                 .   U R                  U5      u  p#U R                  " U0 UD6nUR                  R                  U 5      nUGc  [	        U R
                  [        5      (       a  U R
                  nO[	        [        U R
                  SS5      [        5      (       a  U R
                  R                  nO[	        U R
                  [        5      (       dO  [	        U R
                  [        5      (       a0  UR                  R                  R                  U R
                  5      nO/UR                  R                  R                  U R
                  5      nXQR                  U '   UR                  U5      nUR                  S5      nUb  XvS'   UR                  U5      $ )z
Render the specified template and context. Cache the template object
in render_context to avoid reparsing and loading when used in a for
loop.
Ntemplate
csrf_token)r   r(   render_contextget
isinstancer}   r   getattrr   strr   engineselect_templateget_templatenewr   )r"   r   r   r   _dicttnew_contextr   s           r   r   InclusionNode.renderd  s9    *.)D)DW)M&		=<O<""&&t,9$--22MMGDMM:tDhOOMM**s33
x9 9 $$++;;DMMJ$$++88G+,""4(kk%( [[.
!(2%xx$$r   )r}   )r   r   r   r   r#   r   r   r   r   s   @r   r|   r|   _  s    !% %r   r|   c
           
         U(       a$  U(       a  US   S:X  a  USS nO[        SU	-  5      e/ n
0 n[        U5      nU Vs/ sH  o(       a  X;  d  M  UPM     nnU H  n[        U/U 5      nU(       a  UR                  5       u  nnUU;  a  UU;  a  Uc  [        SU	< SU< S35      eUU;   a  [        SU	< SU< S35      eUU[	        U5      '   UU;   a  UR                  U5        M  UU;   a  UR                  U5        M  M  U(       a  [        S	U	-  5      eU
R                  U R                  U5      5         UR                  S5        M     Ub  US[        U5      *  nU(       d  U(       a+  [        SU	< SSR                  S X-    5       5      < 35      eX4$ s  snf ! [         a    Uc  [        S
U	-  5      e GMf  f = f)z
Parse bits for template tag helpers simple_tag and inclusion_tag, in
particular by detecting syntax errors and by extracting positional and
keyword arguments.
r   r   r
   NzW'%s' is decorated with takes_context=True so it must have a first argument of 'context'rm   z(' received unexpected keyword argument 'z1' received multiple values for keyword argument 'zH'%s' received some positional argument(s) after some keyword argument(s)z+'%s' received too many positional argumentsz0' did not receive value(s) for the argument(s): r,   c              3   *   #    U H
  nS U-  v   M     g7f)z'%s'Nr   ).0ps     r   	<genexpr>parse_bits.<locals>.<genexpr>  s     W3Vavz3Vs   )r   listr   popitemr   removeappendcompile_filterpop
IndexErrorrO   join)rR   rT   r\   r^   r_   rX   rZ   r[   r]   r)   rV   rW   unhandled_paramskwargunhandled_kwargsbitparamrC   s                     r   rP   rP     s	   " fQi9,ABZF%57;<  DFF|!!%E<X6   cUF+ ==?LE5F"uF':u})HLeT  &)U$  &+s5z",, %++E2..$++E2 / )*,01  F11#67$((+M X  ,,<s8}n=+!TYYW3C3VWWY
 	
 <sT " 1IDP  's   FF:F""GGc                      [        U 5      n UR                  $ ! [         a  n[        SU < SU< 35      eSnAff = f! [         a    [        SU -  5      ef = f)z3
Load a Library object from a template tag module.
zLInvalid template library specified. ImportError raised when trying to load 'z': Nz3Module %s does not have a variable named 'register')r   ImportErrorr   registerAttributeError)r)   modulees      r   import_libraryr     sn    
t$
  
$)-q2
 	

  
$ADH
 	

s    ? 
<7<AN)collections.abcr   	functoolsr   	importlibr   inspectr   r   django.utils.htmlr   django.utils.inspectr	   baser   r   r   
exceptionsr   	Exceptionr   r   r   rQ   rq   r|   rP   r   r   r   r   <module>r      sv    $  # * 0 1 . . +	Y 	S Sl.D .* $.j .""%M "%JUp
r   