Sindbad~EG File Manager

Current Path : /proc/2233733/root/usr/local/lib/python3.12/site-packages/flask/__pycache__/
Upload File :
Current File : //proc/2233733/root/usr/local/lib/python3.12/site-packages/flask/__pycache__/ctx.cpython-312.pyc

�

(ٜg;���ddlmZddlZddlZddlZddlmZddlm	Z	ddl
mZddlmZ
ddlmZdd	lmZdd
lmZddlmZej(rddlmZdd
lmZddlmZddlmZe�ZGd�d�Z				dd�Z ejBdejDdejFf��Z$dd�Z%dd�Z&dd�Z'Gd�d�Z(Gd�d�Z)y) �)�annotationsN)�update_wrapper)�
TracebackType)�
HTTPException�)�typing)�_cv_app)�_cv_request)�appcontext_popped)�appcontext_pushed)�WSGIEnvironment)�Flask)�SessionMixin)�Requestc�`�eZdZdZdd�Zd
d�Zdd�Zddd�Zefdd�Z	ddd�Z
dd	�Zdd
�Zdd�Z
y)�_AppCtxGlobalsa�A plain object. Used as a namespace for storing data during an
    application context.

    Creating an app context automatically creates this object, which is
    made available as the :data:`g` proxy.

    .. describe:: 'key' in g

        Check whether an attribute is present.

        .. versionadded:: 0.10

    .. describe:: iter(g)

        Return an iterator over the attribute names.

        .. versionadded:: 0.10
    c�T�	|j|S#t$r
t|�d�wxYw�N��__dict__�KeyError�AttributeError��self�names  �4/usr/local/lib/python3.12/site-packages/flask/ctx.py�__getattr__z_AppCtxGlobals.__getattr__4s2��	1��=�=��&�&���	1� ��&�D�0�	1�s��'c�"�||j|<yr�r)rr�values   r�__setattr__z_AppCtxGlobals.__setattr__:s��#��
�
�d��c�R�	|j|=y#t$r
t|�d�wxYwrrrs  r�__delattr__z_AppCtxGlobals.__delattr__=s/��	1��
�
�d�#���	1� ��&�D�0�	1�s�
�&Nc�:�|jj||�S)z�Get an attribute by name, or a default value. Like
        :meth:`dict.get`.

        :param name: Name of attribute to get.
        :param default: Value to return if the attribute is not present.

        .. versionadded:: 0.10
        )r�get�rr�defaults   rr&z_AppCtxGlobals.getCs���}�}� � ��w�/�/r"c��|tur|jj|�S|jj||�S)aGet and remove an attribute by name. Like :meth:`dict.pop`.

        :param name: Name of attribute to pop.
        :param default: Value to return if the attribute is not present,
            instead of raising a ``KeyError``.

        .. versionadded:: 0.11
        )�	_sentinelr�popr's   rr+z_AppCtxGlobals.popNs8���i���=�=�$�$�T�*�*��=�=�$�$�T�7�3�3r"c�:�|jj||�S)a5Get the value of an attribute if it is present, otherwise
        set and return a default value. Like :meth:`dict.setdefault`.

        :param name: Name of attribute to get.
        :param default: Value to set and return if the attribute is not
            present.

        .. versionadded:: 0.11
        )r�
setdefaultr's   rr-z_AppCtxGlobals.setdefault\s���}�}�'�'��g�6�6r"c��||jvSrr)r�items  r�__contains__z_AppCtxGlobals.__contains__hs���t�}�}�$�$r"c�,�t|j�Sr)�iterr�rs r�__iter__z_AppCtxGlobals.__iter__ks���D�M�M�"�"r"c��tjd�}|�d|jj�d�Stj|�S)Nz
<flask.g of 'z'>)r	r&�appr�object�__repr__)r�ctxs  rr8z_AppCtxGlobals.__repr__ns;���k�k�$����?�"�3�7�7�<�<�.��3�3����t�$�$r")r�str�return�t.Any)rr:r r<r;�None)rr:r;r=r)rr:r(zt.Any | Noner;r<)rr:r(r<r;r<)r/r:r;�bool)r;zt.Iterator[str]�r;r:)�__name__�
__module__�__qualname__�__doc__rr!r$r&r*r+r-r0r4r8�r"rrrs9���,1�$�1�	0�/8�4�
7�%�#�%r"rc��tjd�}|�td��|jj	|�|S)a�Executes a function after this request.  This is useful to modify
    response objects.  The function is passed the response object and has
    to return the same or a new one.

    Example::

        @app.route('/')
        def index():
            @after_this_request
            def add_header(response):
                response.headers['X-Foo'] = 'Parachute'
                return response
            return 'Hello World!'

    This is more useful if a function other than the view function wants to
    modify a response.  For instance think of a decorator that wants to add
    some headers without converting the return value into a response object.

    .. versionadded:: 0.9
    Nzc'after_this_request' can only be used when a request context is active, such as in a view function.)r
r&�RuntimeError�_after_request_functions�append)�fr9s  r�after_this_requestrJusD��.�/�/�$�
�C�
�{��
>�
�	
�
� � �'�'��*��Hr"�F.)�boundc����tjd����td���j��d��fd�}t	|��S)a:A helper function that decorates a function to retain the current
    request context.  This is useful when working with greenlets.  The moment
    the function is decorated a copy of the request context is created and
    then pushed when the function is called.  The current session is also
    included in the copied request context.

    Example::

        import gevent
        from flask import copy_current_request_context

        @app.route('/')
        def index():
            @copy_current_request_context
            def do_some_work():
                # do some work here, it can access flask.request or
                # flask.session like you would otherwise in the view function.
                ...
            gevent.spawn(do_some_work)
            return 'Regular response'

    .. versionadded:: 0.10
    Nzm'copy_current_request_context' can only be used when a request context is active, such as in a view function.c�v���5�jj��|i|��cddd�S#1swYyxYwr)r6�ensure_sync)�args�kwargsr9rIs  ��r�wrapperz-copy_current_request_context.<locals>.wrapper�s.���
�)�3�7�7�&�&�q�)�4�:�6�:��S�S�s�!/�8)rPr<rQr<r;r<)r
r&rF�copyr)rIrRr9s` @r�copy_current_request_contextrT�sL���0�/�/�$�
�C�
�{��
F�
�	
�
�(�(�*�C�;��'�1�%�%r"c�0�tjd�duS)a�If you have code that wants to test if a request context is there or
    not this function can be used.  For instance, you may want to take advantage
    of request information if the request object is available, but fail
    silently if it is unavailable.

    ::

        class User(db.Model):

            def __init__(self, username, remote_addr=None):
                self.username = username
                if remote_addr is None and has_request_context():
                    remote_addr = request.remote_addr
                self.remote_addr = remote_addr

    Alternatively you can also just test any of the context bound objects
    (such as :class:`request` or :class:`g`) for truthness::

        class User(db.Model):

            def __init__(self, username, remote_addr=None):
                self.username = username
                if remote_addr is None and request:
                    remote_addr = request.remote_addr
                self.remote_addr = remote_addr

    .. versionadded:: 0.7
    N)r
r&rDr"r�has_request_contextrV�s��:�?�?�4� ��,�,r"c�0�tjd�duS)z�Works like :func:`has_request_context` but for the application
    context.  You can also just do a boolean check on the
    :data:`current_app` object instead.

    .. versionadded:: 0.9
    N)r	r&rDr"r�has_app_contextrX�s���;�;�t��D�(�(r"c�L�eZdZdZdd�Zd	d�Zefd
d�Zdd�Z								dd�Z	y)
�
AppContextz�The app context contains application-specific information. An app
    context is created and pushed at the beginning of each request if
    one is not already active. An app context is also pushed when
    running CLI commands.
    c�v�||_|jd�|_|j�|_g|_yr)r6�create_url_adapter�url_adapter�app_ctx_globals_class�g�
_cv_tokens)rr6s  r�__init__zAppContext.__init__�s3������1�1�$�7���!$�!:�!:�!<���?A��r"c���|jjtj|��t	j
|j|jj��y)z-Binds the app context to the current context.��_async_wrapperN)r`rHr	�setr�sendr6rOr3s r�pushzAppContext.push�s;�������w�{�{�4�0�1����t�x�x����8L�8L�Mr"c�N�	t|j�dk(r:|turtj�d}|j
j
|�tj�}tj|jj��||urtd|�d|�d���tj|j
|j
j��y#tj�}tj|jj��wxYw)zPops the app context.rzPopped wrong app context. (� instead of �)rcN)�lenr`r*�sys�exc_infor6�do_teardown_appcontextr	r&�resetr+�AssertionErrorrrfrO)r�excr9s   rr+zAppContext.pops���	1��4�?�?�#�q�(��)�#��,�,�.��+�C����/�/��4��+�+�-�C��M�M�$�/�/�-�-�/�0��d�?� �-�c�W�L����J��
�	���t�x�x����8L�8L�M���+�+�-�C��M�M�$�/�/�-�-�/�0�s
�AC!�!AD$c�&�|j�|Sr�rgr3s r�	__enter__zAppContext.__enter__����	�	���r"c�&�|j|�yr�r+�r�exc_type�	exc_value�tbs    r�__exit__zAppContext.__exit__���	
����r"N)r6rr;r=�r;r=�rq�BaseException | Noner;r=)r;rZ�ryztype | Nonerzr�r{zTracebackType | Noner;r=)
r@rArBrCrargr*r+rtr|rDr"rrZrZ�sN���B�N�
/8�N�$����(��
!�	�

�r"rZc�|�eZdZdZ		d									dd�Zd
d�Zdd�Zdd�Zefdd�Z	d
d�Z
								dd	�Zdd
�Zy)�RequestContexta�The request context contains per-request information. The Flask
    app creates and pushes it at the beginning of the request, then pops
    it at the end of the request. It will create the URL adapter and
    request object for the WSGI environment provided.

    Do not attempt to use this class directly, instead use
    :meth:`~flask.Flask.test_request_context` and
    :meth:`~flask.Flask.request_context` to create this object.

    When the request context is popped, it will evaluate all the
    functions registered on the application for teardown execution
    (:meth:`~flask.Flask.teardown_request`).

    The request context is automatically popped at the end of the
    request. When using the interactive debugger, the context will be
    restored so ``request`` is still accessible. Similarly, the test
    client can preserve the context after the request ends. However,
    teardown functions may already have closed some resources such as
    database connections.
    Nc�>�||_|�"|j|�}|j|_||_d|_	|j
|j�|_d|_	||_
g|_g|_y#t$r}||j_Yd}~�<d}~wwxYwr)
r6�
request_class�json�json_module�requestr]r\r�routing_exception�flashes�sessionrGr`)rr6�environr�r��es      rrazRequestContext.__init__5s�������?��'�'��0�G�"%�(�(�G�� '������	/�"�5�5�d�l�l�C�D��6:���,3���OQ��%�
�	
����	/�-.�D�L�L�*�*��	/�s� A8�8	B�B�Bc��|j|j|jj|j|j��S)a5Creates a copy of this request context with the same request object.
        This can be used to move a request context to a different greenlet.
        Because the actual request object is the same this cannot be used to
        move a request context to a different thread unless access to the
        request object is locked.

        .. versionadded:: 0.10

        .. versionchanged:: 1.1
           The current session object is used instead of reloading the original
           data. This prevents `flask.session` pointing to an out-of-date object.
        )r�r�r�)�	__class__r6r�r�r�r3s rrSzRequestContext.copyQs<���~�~��H�H��L�L�(�(��L�L��L�L�	�
�	
r"c���	|jjd��}|\|j_|j_y#t
$r}||j_Yd}~yd}~wwxYw)zZCan be overridden by a subclass to hook into the matching
        of the request.
        T)�return_ruleN)r]�matchr��url_rule�	view_argsrr�)r�resultr�s   r�
match_requestzRequestContext.match_requestesW��	/��%�%�+�+��+�=�F�<B�9�D�L�L�!�4�<�<�#9���	/�-.�D�L�L�*�*��	/�s�?A�	A&�A!�!A&c�H�tjd�}|�|j|jur+|jj�}|j	�nd}|j
j
tj|�|f�|j�m|jj}|j|j|j�|_	|j� |j|j�|_	|j�|j�yyr)r	r&r6�app_contextrgr`rHr
rer��session_interface�open_sessionr��make_null_sessionr]r�)r�app_ctxr�s   rrgzRequestContext.pushos����+�+�d�#���?�g�k�k����9��h�h�*�*�,�G��L�L�N��G���������� 5�w�?�@��<�<�� $��� :� :��,�9�9�$�(�(�D�L�L�Q�D�L��|�|�#�0�B�B�4�8�8�L������'���� �(r"c	� �t|j�dk(}	|rZ|turtj�d}|j
j
|�t|jdd�}|�|�tj�}|jj�\}}tj|�|rd|jjd<|�|j|�||urtd|�d|�d���y#tj�}|jj�\}}tj|�|rd|jjd<|�|j|�||urtd|�d|�d���wxYw)aPops the request context and unbinds it by doing that.  This will
        also trigger the execution of functions registered by the
        :meth:`~flask.Flask.teardown_request` decorator.

        .. versionchanged:: 0.9
           Added the `exc` argument.
        r�closeNzwerkzeug.requestzPopped wrong request context. (rirj)rkr`r*rlrmr6�do_teardown_request�getattrr�r
r&r+ror�rp)rrq�
clear_request�
request_closer9�tokenr�s       rr+zRequestContext.pop�sz���D�O�O�,��1�
�	���)�#��,�,�.��+�C����,�,�S�1� '����g�t� D�
� �,�!�O��/�/�#�C�!�_�_�0�0�2�N�E�7����e�$��:>����#�#�$6�7��"����C� ��$��$�5�c�W�L���PQ�R������/�/�#�C�!�_�_�0�0�2�N�E�7����e�$��:>����#�#�$6�7��"����C� ��$��$�5�c�W�L���PQ�R����s
�AD�BF
c�&�|j�|Srrsr3s rrtzRequestContext.__enter__�rur"c�&�|j|�yrrwrxs    rr|zRequestContext.__exit__�r}r"c	��dt|�j�d|jj�d|jj�d|j
j�d�	S)N�<� z [z] of �>)�typer@r��url�methodr6rr3s rr8zRequestContext.__repr__�sQ����T�
�#�#�$�A�d�l�l�&6�&6�%9�����$�$�%�U�4�8�8�=�=�/��
<�	
r")NN)
r6rr�r
r�zRequest | Noner�zSessionMixin | Noner;r=)r;r�r~rr�r?)
r@rArBrCrarSr�rgr*r+rtr|r8rDr"rr�r�s����2#'�'+��
��!�� �	�
%��
�
�8
�(/�!�:/8�#�J����(��
!�	�

��
r"r�)rI�ft.AfterRequestCallable[t.Any]r;r�)rIrKr;rK)r;r>)*�
__future__r�contextvarsrlr�t�	functoolsr�typesr�werkzeug.exceptionsr��ft�globalsr	r
�signalsrr�
TYPE_CHECKING�_typeshed.wsgir
r6r�sessionsr�wrappersrr7r*rrJ�TypeVar�Callable�AnyrKrTrVrXrZr�rDr"r�<module>r�s���"��
��$��-��� �&�&��?�?�.��&�!�
�H�	�U%�U%�p 
�%� 
�#� 
�F�A�I�I�c����C����J�/�0��&&�R-�@)�.�.�bb
�b
r"

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists