o
    ÕèFhm  ã                   @   sŒ   d dl Z d dlZd dlmZmZmZ G dd„ deƒZG dd„ deƒZ	eZ
e	ZG dd„ dƒZG d	d
„ d
eƒZG dd„ deƒZG dd„ dƒZdS )é    N)ÚiscoroutinefunctionÚmarkcoroutinefunctionÚsync_to_asyncc                   @   ó   e Zd ZdS )ÚRemovedInDjango51WarningN©Ú__name__Ú
__module__Ú__qualname__© r   r   úQ/var/www/html/loop/nvenv/lib/python3.10/site-packages/django/utils/deprecation.pyr      ó    r   c                   @   r   )ÚRemovedInDjango60WarningNr   r   r   r   r   r      r   r   c                   @   s   e Zd Zdd„ Zdd„ ZdS )Úwarn_about_renamed_methodc                 C   s   || _ || _|| _|| _d S )N)Ú
class_nameÚold_method_nameÚnew_method_nameÚdeprecation_warning)Úselfr   r   r   r   r   r   r   Ú__init__   s   
z"warn_about_renamed_method.__init__c                    s   ‡ ‡fdd„}|S )Nc                     s.   t  dˆjˆjˆjf ˆjd¡ ˆ | i |¤ŽS )Nz(`%s.%s` is deprecated, use `%s` instead.é   )ÚwarningsÚwarnr   r   r   r   )ÚargsÚkwargs©Úfr   r   r   Úwrapper   s   ÿüz3warn_about_renamed_method.__call__.<locals>.wrapperr   )r   r   r   r   r   r   Ú__call__   s   	z"warn_about_renamed_method.__call__N)r   r	   r
   r   r   r   r   r   r   r      s    r   c                       s$   e Zd ZdZdZ‡ fdd„Z‡  ZS )ÚRenameMethodsBasea#  
    Handles the deprecation paths when renaming a method.

    It does the following:
        1) Define the new method if missing and complain about it.
        2) Define the old method if missing.
        3) Complain whenever an old method is called.

    See #15363 for more details.
    r   c                    sÌ   t ƒ  | |||¡}t |¡D ]U}|j}| jD ]L}|d }|j |¡}	|d }
|j |
¡}|d }t|g|¢R Ž }|sV|	rVt	 
d|||
f |d¡ t||
|	ƒ t||||	ƒƒ |	sb|rbt||||ƒƒ qq|S )Nr   é   r   z&`%s.%s` method should be renamed `%s`.)ÚsuperÚ__new__ÚinspectÚgetmror   Úrenamed_methodsÚ__dict__Úgetr   r   r   Úsetattr)ÚclsÚnameÚbasesÚattrsÚ	new_classÚbaser   Úrenamed_methodr   Ú
old_methodr   Ú
new_methodr   r   ©Ú	__class__r   r   r"   7   s2   
ÿü€ëzRenameMethodsBase.__new__)r   r	   r
   Ú__doc__r%   r"   Ú__classcell__r   r   r2   r   r   )   s    r   c                       s   e Zd Z‡ fdd„Z‡  ZS )ÚDeprecationInstanceCheckc                    s(   t  d| j| jf | jd¡ tƒ  |¡S )Nz%`%s` is deprecated, use `%s` instead.r   )r   r   r   Úalternativer   r!   Ú__instancecheck__)r   Úinstancer2   r   r   r8   W   s   ýz*DeprecationInstanceCheck.__instancecheck__)r   r	   r
   r8   r5   r   r   r2   r   r6   V   s    r6   c                       sD   e Zd ZdZdZ‡ fdd„Zdd„ Zdd„ Zdd	„ Zd
d„ Z	‡  Z
S )ÚMiddlewareMixinTc                    s,   |d u rt dƒ‚|| _|  ¡  tƒ  ¡  d S )Nzget_response must be provided.)Ú
ValueErrorÚget_responseÚ_async_checkr!   r   )r   r<   r2   r   r   r   d   s
   zMiddlewareMixin.__init__c                 C   s    d| j jt| jd| jj jƒf S )Nz<%s get_response=%s>r
   )r3   r
   Úgetattrr<   r   ©r   r   r   r   Ú__repr__k   s   ýþzMiddlewareMixin.__repr__c                 C   s   t | jƒrt| ƒ dS dS )z�
        If get_response is a coroutine function, turns us into async mode so
        a thread is not consumed during a whole request.
        N)r   r<   r   r?   r   r   r   r=   u   s   
ýzMiddlewareMixin._async_checkc                 C   sR   t | ƒr	|  |¡S d }t| dƒr|  |¡}|p|  |¡}t| dƒr'|  ||¡}|S )NÚprocess_requestÚprocess_response)r   Ú	__acall__ÚhasattrrA   r<   rB   ©r   ÚrequestÚresponser   r   r   r      s   



zMiddlewareMixin.__call__c                 Ã   sd   �d}t | dƒrt| jdd�|ƒI dH }|p|  |¡I dH }t | dƒr0t| jdd�||ƒI dH }|S )zh
        Async version of __call__ that is swapped in when an async request
        is running.
        NrA   T)Úthread_sensitiverB   )rD   r   rA   r<   rB   rE   r   r   r   rC   ‹   s$   €
þ
ý
þ
ýzMiddlewareMixin.__acall__)r   r	   r
   Úsync_capableÚasync_capabler   r@   r=   r   rC   r5   r   r   r2   r   r:   `   s    

r:   )r#   r   Úasgiref.syncr   r   r   ÚDeprecationWarningr   ÚPendingDeprecationWarningr   ÚRemovedInNextVersionWarningÚRemovedAfterNextVersionWarningr   Útyper   r6   r:   r   r   r   r   Ú<module>   s    -
