3
(h9                 @   s   d dl mZ d dlZd dlZG dd deZG dd deZG dd deZ	G d	d
 d
e
ZG dd de
ZG dd dZedZedZG dd deZdS )    )absolute_importNc               @   s   e Zd ZdS )RemovedInDjango20WarningN)__name__
__module____qualname__ r   r   </tmp/pip-install-q3hcpn_q/Django/django/utils/deprecation.pyr      s   r   c               @   s   e Zd ZdS )RemovedInNextVersionWarningN)r   r   r   r   r   r   r   r	      s   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 jdjjjf jd  | |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   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f 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.
    c                s   t t| j| |||}xtj|D ]}|j}x| jD ]}|d }|jj|}	|d }
|jj|
}|d }t	|f| }| r|	rt
jd|||
f |d t||
|	 t||||	 |	 r4|r4t|||| q4W q"W |S )Nr      r   z&`%s.%s` method should be renamed `%s`.)superr   __new__inspectgetmror   renamed_methods__dict__getr
   r   r   setattr)clsnamebasesattrs	new_classbaser   Zrenamed_methodr   Z
old_methodr   Z
new_methodr   wrapper)	__class__r   r   r   .   s(    


zRenameMethodsBase.__new__)r   r   r   __doc__r   r   __classcell__r   r   )r*   r   r       s   
r   c                   s   e Zd Z fddZ  ZS )DeprecationInstanceCheckc                s,   t jd| j| jf | jd tt| j|S )Nz%`%s` is deprecated, use `%s` instead.r   )r   r   r   alternativer   r   r-   __instancecheck__)r   instance)r*   r   r   r/   L   s    
z*DeprecationInstanceCheck.__instancecheck__)r   r   r   r/   r,   r   r   )r*   r   r-   K   s   r-   c               @   sT   e Zd ZdZdZdd Zdd Zdd Zd	d
 Zdd Z	dd Z
dd Zdd ZdS )CallableBoolzS
    An boolean-like object that is also callable for backwards compatibility.
    Tc             C   s
   || _ d S )N)value)r   r2   r   r   r   r   Z   s    zCallableBool.__init__c             C   s   | j S )N)r2   )r   r   r   r   __bool__]   s    zCallableBool.__bool__c             C   s   t jdtdd | jS )NzUsing user.is_authenticated() and user.is_anonymous() as a method is deprecated. Remove the parentheses to use it as an attribute.r   )
stacklevel)r   r   r   r2   )r   r   r   r   r   `   s    
zCallableBool.__call__c             C   s   | j S )N)r2   )r   r   r   r   __nonzero__h   s    zCallableBool.__nonzero__c             C   s
   d| j  S )NzCallableBool(%r))r2   )r   r   r   r   __repr__k   s    zCallableBool.__repr__c             C   s
   | j |kS )N)r2   )r   otherr   r   r   __eq__n   s    zCallableBool.__eq__c             C   s
   | j |kS )N)r2   )r   r7   r   r   r   __ne__q   s    zCallableBool.__ne__c             C   s   t | jp
|S )N)boolr2   )r   r7   r   r   r   __or__t   s    zCallableBool.__or__N)r   r   r   r+   Zdo_not_call_in_templatesr   r3   r   r5   r6   r8   r9   r;   r   r   r   r   r1   T   s   r1   FTc                   s&   e Zd Zd fdd	Zdd Z  ZS )MiddlewareMixinNc                s   || _ tt| j  d S )N)get_responser   r<   r   )r   r=   )r*   r   r   r   |   s    zMiddlewareMixin.__init__c             C   s@   d }t | dr| j|}|s&| j|}t | dr<| j||}|S )Nprocess_requestprocess_response)hasattrr>   r=   r?   )r   requestresponser   r   r   r      s    



zMiddlewareMixin.__call__)N)r   r   r   r   r   r,   r   r   )r*   r   r<   {   s   r<   )
__future__r   r   r   PendingDeprecationWarningr   DeprecationWarningr	   objectr
   typer   r-   r1   ZCallableFalseZCallableTruer<   r   r   r   r   <module>   s   +	#