o
    jTteN                     @   s   d dl Z d dlZd dlZd dlmZ G dd deZG dd d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)sync_to_asyncc                   @      e Zd ZdS )RemovedInDjango40WarningN__name__
__module____qualname__ r	   r	   d/var/www/social.2tendo.club/virtuCedar/venv/lib/python3.10/site-packages/django/utils/deprecation.pyr          r   c                   @   r   )RemovedInDjango41WarningNr   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
   wrapped   s   z3warn_about_renamed_method.__call__.<locals>.wrappedr	   )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   wrapper	__class__r	   r
   r!   2   s0   
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   P   s
   z*DeprecationInstanceCheck.__instancecheck__)r   r   r   r8   r5   r	   r	   r2   r
   r6   O   s    r6   c                       sF   e Zd ZdZdZd fdd	Zdd Zdd Zd	d
 Zdd Z	  Z
S )MiddlewareMixinTNc                    s&   |  | || _|   t   d S r   )_get_response_none_deprecationget_response_async_checkr    r   r   r<   r2   r	   r
   r   ^   s   
zMiddlewareMixin.__init__c                 C   s   t | jrt jj| _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)asyncioiscoroutinefunctionr<   
coroutines_is_coroutine)r   r	   r	   r
   r=   d   s   zMiddlewareMixin._async_checkc                 C   sV   t | jr| |S d }t| dr| |}|p| |}t| dr)| ||}|S )Nprocess_requestprocess_response)r?   r@   r<   	__acall__hasattrrC   rD   r   requestresponser	   r	   r
   r   n   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.
        NrC   T)thread_sensitiverD   )rF   r   rC   r<   rD   rG   r	   r	   r
   rE   z   s$   



zMiddlewareMixin.__acall__c                 C   s    |d u rt jdtdd d S d S )NzDPassing None for the middleware get_response argument is deprecated.   )
stacklevel)r   r   r   r>   r	   r	   r
   r;      s   
z.MiddlewareMixin._get_response_none_deprecationr   )r   r   r   sync_capableasync_capabler   r=   r   rE   r;   r5   r	   r	   r2   r
   r:   X   s    
r:   )r?   r"   r   asgiref.syncr   DeprecationWarningr   PendingDeprecationWarningr   RemovedInNextVersionWarningr   typer   r6   r:   r	   r	   r	   r
   <module>   s    +	