https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/django/template/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/django/template/__pycache__/library.cpython-310.pyc
o

3�a2�@s�ddlZddlmZddlmZmZddlmZddlm	Z	ddl
mZmZm
Z
ddlmZGd	d
�d
e�ZGdd�d�ZGd
d�de�ZGdd�de�ZGdd�de�Zdd�Zdd�ZdS)�N)�
import_module)�getfullargspec�unwrap)�conditional_escape)�is_iterable�)�Node�Template�token_kwargs)�TemplateSyntaxErrorc@seZdZdS)�InvalidTemplateLibraryN)�__name__�
__module__�__qualname__�rr�9/usr/lib/python3/dist-packages/django/template/library.pyrsrc@sPeZdZdZdd�Zddd�Zdd�Zdd	d
�Zdd�Zdd
d�Z	ddd�Z
dS)�Librarya
    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.
    cCsi|_i|_dS�N)�filters�tags)�selfrrr�__init__s
zLibrary.__init__Ncsx�dur|dur�jS�dur%|dur%t��r����S��fdd�}|S�dur4|dur4|�j�<|Std�|f��)Ncs���|�Sr)�tag��func��namerrr�dec%szLibrary.tag.<locals>.decz.Unsupported arguments to Library.tag: (%r, %r))�tag_function�callabler�
ValueError)rr�compile_functionrrrrrs

��zLibrary.tagcCs||jt|d|�j<|S�N�_decorated_function)r�getattrr
)rrrrrr2szLibrary.tag_functioncs��dur|dur��fdd�}|S�dur0|dur0t��r&�j�fi���S���fdd�}|S�dura|dura|�j�<dD]}|�vr[�|}t|||�t|d�r[t|j||�q?�|_|Std�|f��)z�
        Register a callable as a template filter. Example:

        @register.filter
        def lower(value):
            return value.lower()
        Ncs�j|fi���Sr)�filter_functionr)�flagsrrrr@szLibrary.filter.<locals>.deccs�j�|fi���Sr)�filterr�r&rrrrrIs)�expects_localtime�is_safe�needs_autoescaper#z1Unsupported arguments to Library.filter: (%r, %r))rr%r�setattr�hasattrr#�_filter_namer )rr�filter_funcr&r�attr�valuerr(rr'6s0

���zLibrary.filtercKs"t|d|�j}|j||fi|��Sr")r$r
r')rrr&rrrrr%`szLibrary.filter_functioncs4���fdd�}|dur|St|�r||�Std��)z�
        Register a callable as a compiled template tag. Example:

        @register.simple_tag
        def hello(*args, **kwargs):
            return 'world'
        c
sbtt���\������}�pt�d��j�t����������
��f	dd��}�	��|��S)Nr#csn|��dd�}d}t|�dkr |ddkr |d}|dd�}t||���������
\}}t��|||�S)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�varkwrr�compile_funcps�z5Library.simple_tag.<locals>.dec.<locals>.compile_func�rrr$r
�	functools�wrapsr�r�_rH�rrrE�r@rrArBrCrDrFrGrrlszLibrary.simple_tag.<locals>.decNz(Invalid arguments provided to simple_tag)rr )rrrErrrrNr�
simple_tagdszLibrary.simple_tagcs����fdd�}|S)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}
        csdtt���\������}�	pt�d��j�t�������������f
dd��}�
��|��S)Nr#cs>|��dd�}t||���	������
\}}t��||��S)Nr)r6r8�
InclusionNode)r:r;r<r>r?)
r@�filenamerrArBrCrDrErFrGrrrH�s�
�z8Library.inclusion_tag.<locals>.dec.<locals>.compile_funcrIrL�rRrrrErOrr�s 	z"Library.inclusion_tag.<locals>.decr)rrRrrErrrrSr�
inclusion_tag�s	zLibrary.inclusion_tag)NN)NNN)r
rr�__doc__rrrr'r%rPrTrrrrrs

*
$rc@s eZdZdZdd�Zdd�ZdS)�
TagHelperNodez�
    Base class for tag helper nodes such as SimpleNode and InclusionNode.
    Manages the positional and keyword arguments to be passed to the decorated
    function.
    cCs||_||_||_||_dSr)rrEr>r?)rrrEr>r?rrrr�s
zTagHelperNode.__init__csD�fdd�|jD�}|jr�g|}�fdd�|j��D�}||fS)Ncsg|]}|����qSr��resolve)�.0�var��contextrr�
<listcomp>�sz8TagHelperNode.get_resolved_arguments.<locals>.<listcomp>csi|]
\}}||����qSrrW)rY�k�vr[rr�
<dictcomp>�sz8TagHelperNode.get_resolved_arguments.<locals>.<dictcomp>)r>rEr?�items)rr\�
resolved_args�resolved_kwargsrr[r�get_resolved_arguments�s

z$TagHelperNode.get_resolved_argumentsN)r
rrrUrrdrrrrrV�srVc�$eZdZ�fdd�Zdd�Z�ZS)r9c�t��||||�||_dSr)�superrr=)rrrEr>r?r=��	__class__rrr��
zSimpleNode.__init__cCsH|�|�\}}|j|i|��}|jdur|||j<dS|jr"t|�}|S)N�)rdrr=�
autoescaper)rr\rbrc�outputrrr�render�s

zSimpleNode.render�r
rrrrn�
__classcell__rrrhrr9��r9cre)rQcrfr)rgrrR)rrrEr>r?rRrhrrr�rjzInclusionNode.__init__cCs�|�|�\}}|j|i|��}|j�|�}|durSt|jt�r#|j}n+tt|jdd�t�r2|jj}nt|jt	�sFt
|j�rF|jj�|j�}n|jj�
|j�}||j|<|�|�}|�d�}|dure||d<|�|�S)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)rdr�render_context�get�
isinstancerRr	r$rr�strr�engine�select_template�get_template�newrn)rr\rbrc�_dict�t�new_contextrsrrrrn�s"




zInclusionNode.renderrorrrhrrQ�rqrQc
	s�|r|ddkr|dd�}ntd|	��g}
i}t|�}�fdd�|D�}
|D]t}t|g|�}|rr|��\}}||vrL||vrL|durLtd|	|f��||vrXtd	|	|f��||t|�<||vrh|�|�q(||
vrq|
�|�q(|rztd
|	��|
�|�|��z|�d�Wq(t	y�|dur�td|	��Yq(w|dur�|dt
|��}|s�|
r�td|	d
�dd�||
D��f��|
|fS)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.
    rr\rNzW'%s' is decorated with takes_context=True so it must have a first argument of 'context'csg|]
}�r
|�vr|�qSrr)rY�kwarg�rCrrr]�s��zparse_bits.<locals>.<listcomp>z.'%s' received unexpected keyword argument '%s'z7'%s' received multiple values for keyword argument '%s'zH'%s' received some positional argument(s) after some keyword argument(s)z+'%s' received too many positional argumentsz5'%s' did not receive value(s) for the argument(s): %sz, css�|]}d|VqdS)z'%s'Nr)rY�prrr�	<genexpr>4s�zparse_bits.<locals>.<genexpr>)r�listr
�popitemrw�remove�append�compile_filter�pop�
IndexErrorr7�join)r:r<rDrFrGr@rBrCrErr>r?�unhandled_params�unhandled_kwargs�bitr�paramr1rr�rr8�s~��
�����
���������r8c
CsZzt|�}Wnty}ztd||f��d}~wwz|jWSty,td|��w)z;
    Load a Library object from a template tag module.
    zSInvalid template library specified. ImportError raised when trying to load '%s': %sNz4Module  %s does not have a variable named 'register')r�ImportErrorr�register�AttributeError)r�module�errr�import_library8s"������r�)rJ�	importlibr�inspectrr�django.utils.htmlr�django.utils.itercompatr�baserr	r
�
exceptionsr�	ExceptionrrrVr9rQr8r�rrrr�<module>s$K

https://t.me/RX1948 - 2025