AlkantarClanX12

Your IP : 18.225.149.158


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

�

l��fk/���dZddlZddlZddlZddlZddlZddlZddlmZddlm	Z	ddlm
Z
ddlmZddlm
Z
dd	lmZdd
lmZddlmZddlmZd
Zdejed��zejejddzejdzd��zZGd�de��ZGd�de��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)�listdir)�path�)�BytesIO)�marshal_dump)�marshal_load)�pickle)�	text_type)�open_if_exists�sj2��c�6�eZdZdZd�Zd�Zd�Zd�Zd�Zd�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.
    c�X�||_||_||_|���dS�N)�environment�key�checksum�reset)�selfrrrs    �n/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib/python3.11/site-packages/jinja2/bccache.py�__init__zBucket.__init__.s)��&������ ��
��
�
������c��d|_dS)z)Resets the bucket (unloads the bytecode).N)�code�rs rrzBucket.reset4s
����	�	�	rc��|�tt����}|tkr|���dSt	j|��}|j|kr|���dS	t|��|_dS#tttf$r|���YdSwxYw)z/Loads bytecode from a file or file like object.N)�read�len�bc_magicrr
�loadrr	r�EOFError�
ValueError�	TypeError)r�f�magicrs    r�
load_bytecodezBucket.load_bytecode8s������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�Cc���|j�td���|�t��t	j|j|d��t|j|��dS)z;Dump the bytecode into the file or file like object passed.Nzcan't write empty bucketr)rr&�writer"r
�dumprr)rr's  r�write_bytecodezBucket.write_bytecodeKsY���9���6�7�7�7�	���������D�M�1�a�(�(�(��T�Y��"�"�"�"�"rc�J�|�t|����dS)zLoad bytecode from a string.N)r)r)r�strings  r�bytecode_from_stringzBucket.bytecode_from_stringSs"�����7�6�?�?�+�+�+�+�+rc�p�t��}|�|��|���S)zReturn the bytecode as string.)rr-�getvalue)r�outs  r�bytecode_to_stringzBucket.bytecode_to_stringWs-���i�i�����C� � � ��|�|�~�~�rN)
�__name__�
__module__�__qualname__�__doc__rrr)r-r0r4�rrrr%sx�����������������&#�#�#�,�,�,�����rrc�>�eZdZdZd�Zd�Zd�Zd
d�Zd�Zd�Z	d	�Z
dS)�
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.
    c��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�r�buckets  rr)zBytecodeCache.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.
        r=r?s  r�
dump_bytecodezBytecodeCache.dump_bytecode�rArc��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.
        Nr9rs r�clearzBytecodeCache.clear�s���rNc��t|�d����}|�Dd|z}t|t��r|�d��}|�|��|���S)z3Returns the unique hash key for this template name.�utf-8N�|)r�encode�
isinstancer�update�	hexdigest)r�name�filename�hashs    r�
get_cache_keyzBytecodeCache.get_cache_key�so���D�K�K��(�(�)�)�����X�~�H��(�I�.�.�
4�#�?�?�7�3�3���K�K��!�!�!��~�~���rc�j�t|�d�������S)z"Returns a checksum for the source.rG)rrIrL)r�sources  r�get_source_checksumz!BytecodeCache.get_source_checksum�s(���F�M�M�'�*�*�+�+�5�5�7�7�7rc��|�||��}|�|��}t|||��}|�|��|S)zwReturn a cache bucket for the given template.  All arguments are
        mandatory but filename may be `None`.
        )rPrSrr))rrrMrNrRrrr@s        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)rCr?s  r�
set_bucketzBytecodeCache.set_bucket�s�����6�"�"�"�"�"rr)r5r6r7r8r)rCrErPrSrUrWr9rrr;r;^s���������8$�$�$�$�$�$���� � � � �8�8�8����#�#�#�#�#rr;c�8�eZdZdZd
d�Zd�Zd�Zd�Zd�Zd	�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.cachec�N�|�|���}||_||_dSr)�_get_default_cache_dir�	directory�pattern)rr]r^s   rrz FileSystemBytecodeCache.__init__�s+�����3�3�5�5�I�"�������rc� �d�}tj��}tjdkr|St	td��s
|��dtj��z}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)Nc� �td���)NzJCannot determine safe temp directory.  You need to explicitly provide one.)�RuntimeErrorr9rr�_unsafe_dirzCFileSystemBytecodeCache._get_default_cache_dir.<locals>._unsafe_dir�s���2���
r�nt�getuidz_jinja2-cache-%d)�tempfile�
gettempdir�osrM�hasattrrdr�join�mkdir�stat�S_IRWXU�OSError�errno�EEXIST�chmod�lstat�st_uid�S_ISDIR�st_mode�S_IMODE)rrb�tmpdir�dirname�
actual_dir�e�actual_dir_stats       rr\z.FileSystemBytecodeCache._get_default_cache_dir�s���	�	�	��$�&�&���7�d�?�?��M��r�8�$�$�	��K�M�M�M�$�r�y�{�{�2���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�1F�Fc�P�tj|j|j|jz��Sr)rrir]r^rr?s  r�_get_cache_filenamez+FileSystemBytecodeCache._get_cache_filename�s���y������
�)B�C�C�Crc���t|�|��d��}|�E	|�|��|���dS#|���wxYwdS)N�rb)rr|r)�close�rr@r's   rr)z%FileSystemBytecodeCache.load_bytecode�sg���4�3�3�F�;�;�T�B�B���=�
��$�$�Q�'�'�'����	�	�	�	�	�����	�	�	�	����	�=s�A�A(c���t|�|��d��}	|�|��|���dS#|���wxYw)N�wb)�openr|r-rr�s   rrCz%FileSystemBytecodeCache.dump_bytecode�s[����)�)�&�1�1�4�8�8��	��!�!�!�$�$�$�
�G�G�I�I�I�I�I��A�G�G�I�I�I�I���s�A�A&c���ddlm}tjt	|j��|jdz��}|D]6}	|tj|j|�����'#t$rY�3wxYwdS)Nr)�remove�*)
rgr��fnmatch�filterrr]r^rrirm)rr��filesrNs    rrEzFileSystemBytecodeCache.clears���	��������w�t�~�6�6���s�8J�K�K���	�	�H�
���t�y����:�:�;�;�;�;���
�
�
���
����	�	s�#A�
A,�+A,)NrZ)
r5r6r7r8rr\r|r)rCrEr9rrrYrY�s���������"����-�-�-�^D�D�D�����������rrYc�,�eZdZdZ			dd�Zd�Zd�ZdS)	�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 unicode.  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/NTc�>�||_||_||_||_dSr)�client�prefix�timeout�ignore_memcache_errors)rr�r�r�r�s     rrzMemcachedBytecodeCache.__init__@s'�����������&<��#�#�#rc��	|j�|j|jz��}n#t$r
|js�d}YnwxYw|�|�|��dSdSr)r��getr�r�	Exceptionr�r0)rr@rs   rr)z$MemcachedBytecodeCache.load_bytecodeLs���	��;�?�?�4�;���#;�<�<�D�D���	�	�	��.�
���D�D�D�	�������'�'��-�-�-�-�-��s�'*�A�Ac���|j|jz|���f}|j�||jfz
}	|jj|�dS#t$r|js�YdSwxYwr)r�rr4r�r��setr�r�)rr@�argss   rrCz$MemcachedBytecodeCache.dump_bytecodeVs�����f�j�(�&�*C�*C�*E�*E�F���<�#��T�\�O�#�D�	��D�K�O�T�"�"�"�"���	�	�	��.�
��
�
�
�	���s�A�A�A)r�NT)r5r6r7r8rr)rCr9rrr�r�s\������*�*�^"��#�
=�
=�
=�
=�.�.�.�����rr�)r8rnr�rgrk�sysre�hashlibrrr�_compatrrr	r
r�utilsr�
bc_version�dumps�version_infor"�objectrr;rYr�r9rr�<module>r�s����
��������	�	�	�	�����
�
�
�
�����������������������������!�!�!�!�!�!�!�!�!�!�!�!�������������!�!�!�!�!�!�
�
�

��f�l�:�q�!�!�"��f�l�C�$�Q�'�2�-��1A�!�1D�D�a�H�H�I�	�6�6�6�6�6�V�6�6�6�rK#�K#�K#�K#�K#�F�K#�K#�K#�\d�d�d�d�d�m�d�d�d�NK�K�K�K�K�]�K�K�K�K�Kr