Hacked By AnonymousFox

Current Path : /opt/cloudlinux/venv/lib/python3.11/site-packages/jinja2/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib/python3.11/site-packages/jinja2/__pycache__/bccache.cpython-311.pyc

�

�܋f~1���dZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z
ddlmZddl
mZddlmZe
jrddlZddlmZGd�d	ej��Zd
Zdejed��zejejdd
zejdzd��zZGd�d��ZGd�d��ZGd�de��ZGd�de��ZdS)a The optional bytecode cache system. This is useful if you have very
complex template situations and the compilation of all those templates
slows down your application too much.

Situations where this is useful are often forking web applications that
are initialized on the first request.
�N)�sha1)�BytesIO)�CodeType�)�Environmentc	�N�eZdZdedefd�Zddededejeddfd�Z	dS)	�_MemcachedClient�key�returnc��dS�N�)�selfr
s  �E/opt/cloudlinux/venv/lib64/python3.11/site-packages/jinja2/bccache.py�getz_MemcachedClient.get����C�N�value�timeoutc��dSr
r)rr
rrs    r�setz_MemcachedClient.setrrr
)
�__name__�
__module__�__qualname__�str�bytesr�t�Optional�intrrrrr	r	sr������	�3�	�5�	�	�	�	�	�	�3�	�u�	�q�z�#��	�RV�	�	�	�	�	�	rr	�sj2��c��eZdZdZdddededdfd�Zdd	�Zd
ejddfd�Z	d
ejddfd�Z
d
eddfd�Zdefd�Z
dS)�BucketauBuckets are used to store the bytecode for one template.  It's created
    and initialized by the bytecode cache and passed to the loading functions.

    The buckets get an internal checksum from the cache assigned and use this
    to automatically reject outdated cache material.  Individual bytecode
    cache subclasses don't have to care about cache invalidation.
    �environmentrr
�checksumrNc�X�||_||_||_|���dSr
)r%r
r&�reset)rr%r
r&s    r�__init__zBucket.__init__5s)��&������ ��
��
�
�����rc��d|_dS)z)Resets the bucket (unloads the bytecode).N)�code�rs rr(zBucket.reset;s
��*.��	�	�	r�fc��|�tt����}|tkr|���dSt	j|��}|j|kr|���dS	tj|��|_dS#tttf$r|���YdSwxYw)z/Loads bytecode from a file or file like object.N)�read�len�bc_magicr(�pickle�loadr&�marshalr+�EOFError�
ValueError�	TypeError)rr-�magicr&s    r�
load_bytecodezBucket.load_bytecode?s������s�8�}�}�%�%���H����J�J�L�L�L��F��;�q�>�>���=�H�$�$��J�J�L�L�L��F�	���Q���D�I�I�I���*�i�0�	�	�	��J�J�L�L�L��F�F�	���s�?B�+C	�C	c���|j�td���|�t��t	j|j|d��tj|j|��dS)z;Dump the bytecode into the file or file like object passed.Nzcan't write empty bucketr!)r+r7�writer1r2�dumpr&r4)rr-s  r�write_bytecodezBucket.write_bytecodeRs[���9���6�7�7�7�	���������D�M�1�a�(�(�(���T�Y��"�"�"�"�"r�stringc�J�|�t|����dS)zLoad bytecode from bytes.N)r9r)rr>s  r�bytecode_from_stringzBucket.bytecode_from_stringZs"�����7�6�?�?�+�+�+�+�+rc�p�t��}|�|��|���S)zReturn the bytecode as bytes.)rr=�getvalue)r�outs  r�bytecode_to_stringzBucket.bytecode_to_string^s-���i�i�����C� � � ��|�|�~�~�r�rN)rrr�__doc__rr)r(r�BinaryIOr9r=rr@rDrrrr$r$,s����������M����s��t�����/�/�/�/��q�z��d�����&#��
�#�t�#�#�#�#�,�5�,�T�,�,�,�,��E������rr$c
���eZdZdZdeddfd�Zdeddfd�Zdd�Z	dded	e	j
e	jedefd
�Zdedefd�Z
d
dded	e	j
ededef
d�Zdeddfd�ZdS)�
BytecodeCachea�To implement your own bytecode cache you have to subclass this class
    and override :meth:`load_bytecode` and :meth:`dump_bytecode`.  Both of
    these methods are passed a :class:`~jinja2.bccache.Bucket`.

    A very basic bytecode cache that saves the bytecode on the file system::

        from os import path

        class MyCache(BytecodeCache):

            def __init__(self, directory):
                self.directory = directory

            def load_bytecode(self, bucket):
                filename = path.join(self.directory, bucket.key)
                if path.exists(filename):
                    with open(filename, 'rb') as f:
                        bucket.load_bytecode(f)

            def dump_bytecode(self, bucket):
                filename = path.join(self.directory, bucket.key)
                with open(filename, 'wb') as f:
                    bucket.write_bytecode(f)

    A more advanced version of a filesystem based bytecode cache is part of
    Jinja.
    �bucketrNc��t���)z�Subclasses have to override this method to load bytecode into a
        bucket.  If they are not able to find code in the cache for the
        bucket, it must not do anything.
        ��NotImplementedError�rrJs  rr9zBytecodeCache.load_bytecode����
"�#�#�#rc��t���)z�Subclasses have to override this method to write the bytecode
        from a bucket back to the cache.  If it unable to do so it must not
        fail silently but raise an exception.
        rLrNs  r�
dump_bytecodezBytecodeCache.dump_bytecode�rOrc��dS)z�Clears the cache.  This method is not used by Jinja but should be
        implemented to allow applications to clear the bytecode cache used
        by a particular environment.
        Nrr,s r�clearzBytecodeCache.clear�s���r�name�filenamec���t|�d����}|�*|�d|�������|���S)z3Returns the unique hash key for this template name.�utf-8N�|)r�encode�update�	hexdigest)rrTrU�hashs    r�
get_cache_keyzBytecodeCache.get_cache_key�sW���D�K�K��(�(�)�)�����K�K��H���-�-�/�/�0�0�0��~�~���r�sourcec�j�t|�d�������S)z"Returns a checksum for the source.rW)rrYr[)rr^s  r�get_source_checksumz!BytecodeCache.get_source_checksum�s(���F�M�M�'�*�*�+�+�5�5�7�7�7rr%rc��|�||��}|�|��}t|||��}|�|��|S)zwReturn a cache bucket for the given template.  All arguments are
        mandatory but filename may be `None`.
        )r]r`r$r9)rr%rTrUr^r
r&rJs        r�
get_bucketzBytecodeCache.get_bucket�sV��� � ��x�0�0���+�+�F�3�3����S�(�3�3�����6�"�"�"��
rc�0�|�|��dS)zPut the bucket into the cache.N)rQrNs  r�
set_bucketzBytecodeCache.set_bucket�s�����6�"�"�"�"�"rrEr
)rrrrFr$r9rQrSrrr�Unionr]r`rbrdrrrrIrIesH��������8$�F�$�t�$�$�$�$�$�F�$�t�$�$�$�$�����?C�	 �	 ��	 �#$�:�a�g�c�l�#;�	 �	�	 �	 �	 �	 �8�#�8�#�8�8�8�8��"�����*�S�/�	�
��
�
���� #��#�D�#�#�#�#�#�#rrIc��eZdZdZ	ddejededdfd�Zdefd�Zd	e	defd
�Z
d	e	ddfd�Zd	e	ddfd�Zdd
�Z
dS)�FileSystemBytecodeCachea�A bytecode cache that stores bytecode on the filesystem.  It accepts
    two arguments: The directory where the cache items are stored and a
    pattern string that is used to build the filename.

    If no directory is specified a default cache directory is selected.  On
    Windows the user's temp directory is used, on UNIX systems a directory
    is created for the user in the system temp directory.

    The pattern can be used to have multiple separate caches operate on the
    same directory.  The default pattern is ``'__jinja2_%s.cache'``.  ``%s``
    is replaced with the cache key.

    >>> bcc = FileSystemBytecodeCache('/tmp/jinja_cache', '%s.cache')

    This bytecode cache supports clearing of the cache using the clear method.
    N�__jinja2_%s.cache�	directory�patternrc�N�|�|���}||_||_dSr
)�_get_default_cache_dirrirj)rrirjs   rr)z FileSystemBytecodeCache.__init__�s-�����3�3�5�5�I�"�������rc�"�dd�}tj��}tjdkr|St	td��s
|��dtj����}tj�||��}	tj|tj
��n-#t$r }|jtj
kr�Yd}~nd}~wwxYw	tj|tj
��tj|��}|jtj��ks@tj|j��r'tj|j��tj
kr
|��n-#t$r }|jtj
kr�Yd}~nd}~wwxYwtj|��}|jtj��ks@tj|j��r'tj|j��tj
kr
|��|S)Nr�te.NoReturnc� �td���)NzJCannot determine safe temp directory.  You need to explicitly provide one.)�RuntimeErrorrrr�_unsafe_dirzCFileSystemBytecodeCache._get_default_cache_dir.<locals>._unsafe_dir�s���2���
r�nt�getuidz_jinja2-cache-)rrn)�tempfile�
gettempdir�osrT�hasattrrs�path�join�mkdir�stat�S_IRWXU�OSError�errno�EEXIST�chmod�lstat�st_uid�S_ISDIR�st_mode�S_IMODE)rrq�tmpdir�dirname�
actual_dir�e�actual_dir_stats       rrlz.FileSystemBytecodeCache._get_default_cache_dir�s���	�	�	�	��$�&�&���7�d�?�?��M��r�8�$�$�	��K�M�M�M�0�2�9�;�;�0�0���W�\�\�&�'�2�2�
�	��H�Z���.�.�.�.���	�	�	��w�%�,�&�&��'�&�&�&�&�����	����	��H�Z���.�.�.� �h�z�2�2�O��&�"�)�+�+�5�5��|�O�$;�<�<�6��<�� 7�8�8�D�L�H�H���
�
�
����	�	�	��w�%�,�&�&��'�&�&�&�&�����	�����(�:�.�.���"�b�i�k�k�1�1��<�� 7�8�8�
2��|�O�3�4�4���D�D��K�M�M�M��s1�B � 
C
�*C�C
�BE(�(
F�2F
�
FrJc�h�tj�|j|j|jfz��Sr
)rvrxryrirjr
rNs  r�_get_cache_filenamez+FileSystemBytecodeCache._get_cache_filenames%���w�|�|�D�N�D�L�F�J�=�,H�I�I�Irc���|�|��}tj�|��r@t	|d��5}|�|��ddd��dS#1swxYwYdSdS)N�rb)r�rvrx�exists�openr9)rrJrUr-s    rr9z%FileSystemBytecodeCache.load_bytecodes����+�+�F�3�3��
�7�>�>�(�#�#�	(��h��%�%�
(���$�$�Q�'�'�'�
(�
(�
(�
(�
(�
(�
(�
(�
(�
(�
(�
(����
(�
(�
(�
(�
(�
(�	(�	(s�A(�(A,�/A,c��t|�|��d��5}|�|��ddd��dS#1swxYwYdS)N�wb)r�r�r=)rrJr-s   rrQz%FileSystemBytecodeCache.dump_bytecode
s���
�$�*�*�6�2�2�D�
9�
9�	%�Q��!�!�!�$�$�$�	%�	%�	%�	%�	%�	%�	%�	%�	%�	%�	%�	%����	%�	%�	%�	%�	%�	%s�A�A�Ac��ddlm}tjtj|j��|jdz��}|D]A}	|tj�|j|�����2#t$rY�>wxYwdS)Nr)�remove)�*)
rvr��fnmatch�filter�listdirrirjrxryr})rr��filesrUs    rrSzFileSystemBytecodeCache.clears���	��������r�z�$�.�9�9�4�<�&�;P�Q�Q���	�	�H�
���r�w�|�|�D�N�H�=�=�>�>�>�>���
�
�
���
����	�	s�.A/�/
A<�;A<)NrhrE)rrrrFrrrr)rlr$r�r9rQrSrrrrgrg�s���������$AT�����C���:=��	
�����-��-�-�-�-�^J�&�J�S�J�J�J�J�(�F�(�t�(�(�(�(�%�F�%�t�%�%�%�%������rrgc	�h�eZdZdZ			ddddedejed	efd
�Z	de
ddfd
�Zde
ddfd�ZdS)�MemcachedBytecodeCachea'This class implements a bytecode cache that uses a memcache cache for
    storing the information.  It does not enforce a specific memcache library
    (tummy's memcache or cmemcache) but will accept any class that provides
    the minimal interface required.

    Libraries compatible with this class:

    -   `cachelib <https://github.com/pallets/cachelib>`_
    -   `python-memcached <https://pypi.org/project/python-memcached/>`_

    (Unfortunately the django cache interface is not compatible because it
    does not support storing binary data, only text. You can however pass
    the underlying cache client to the bytecode cache which is available
    as `django.core.cache.cache._client`.)

    The minimal interface for the client passed to the constructor is this:

    .. class:: MinimalClientInterface

        .. method:: set(key, value[, timeout])

            Stores the bytecode in the cache.  `value` is a string and
            `timeout` the timeout of the key.  If timeout is not provided
            a default timeout or no timeout should be assumed, if it's
            provided it's an integer with the number of seconds the cache
            item should exist.

        .. method:: get(key)

            Returns the value for the cache key.  If the item does not
            exist in the cache the return value must be `None`.

    The other arguments to the constructor are the prefix for all keys that
    is added before the actual cache key and the timeout for the bytecode in
    the cache system.  We recommend a high (or no) timeout.

    This bytecode cache does not support clearing of used items in the cache.
    The clear method is a no-operation function.

    .. versionadded:: 2.7
       Added support for ignoring memcache errors through the
       `ignore_memcache_errors` parameter.
    �jinja2/bytecode/NT�clientr	�prefixr�ignore_memcache_errorsc�>�||_||_||_||_dSr
)r�r�rr�)rr�r�rr�s     rr)zMemcachedBytecodeCache.__init__Ls'�����������&<��#�#�#rrJrc��	|j�|j|jz��}|�|��dS#t
$r|js�YdSwxYwr
)r�rr�r
r@�	Exceptionr�)rrJr+s   rr9z$MemcachedBytecodeCache.load_bytecodeXsy��	.��;�?�?�4�;���#;�<�<�D�

�'�'��-�-�-�-�-��	�	�	�	��.�
��
�
�
�	���s�'A�A�Ac�
�|j|jz}|���}	|j�#|j�|||j��dS|j�||��dS#t$r|js�YdSwxYwr
)r�r
rDrr�rr�r�)rrJr
rs    rrQz$MemcachedBytecodeCache.dump_bytecodeas����k�F�J�&���)�)�+�+��	��|�'������U�D�L�9�9�9�9�9������U�+�+�+�+�+���	�	�	��.�
��
�
�
�	���s�(A,�A,�,B�B)r�NT)
rrrrFrrrr�boolr)r$r9rQrrrr�r�s�������*�*�^)�#'�'+�
=�
=�"�
=��
=���C��	
=�
!%�
=�
=�
=�
=�.�F�.�t�.�.�.�.��F��t������rr�) rFr~r�r4rvr2r{�sysrt�typingr�hashlibr�ior�typesr�
TYPE_CHECKING�typing_extensions�ter%r�Protocolr	�
bc_version�dumps�version_infor1r$rIrgr�rrr�<module>r�s����
������������	�	�	�	�
�
�
�
�����
�
�
�
����������������������������?�	�"�"�"�"�(�(�(�(�(�(������2�;�����
�

��f�l�:�q�!�!�"��f�l�C�$�Q�'�2�-��1A�!�1D�D�a�H�H�I�	�6�6�6�6�6�6�6�6�rR#�R#�R#�R#�R#�R#�R#�R#�jb�b�b�b�b�m�b�b�b�JM�M�M�M�M�]�M�M�M�M�Mr

Hacked By AnonymousFox1.0, Coded By AnonymousFox