3
š(ƒhú  ã               @   sD  d Z ddlmZ ddlm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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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#eƒZG d$d%„ d%eƒZd&ZG d'd(„ d(eƒZd)S )*z.
Global Django exception and warning classes.
é    )Úsix)Ú
force_textc               @   s   e Zd ZdZdS )ÚFieldDoesNotExistz(The requested model field does not existN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__© r	   r	   ú:/tmp/pip-install-q3hcpn_q/Django/django/core/exceptions.pyr      s   r   c               @   s   e Zd ZdS )ÚDjangoRuntimeWarningN)r   r   r   r	   r	   r	   r
   r      s   r   c               @   s   e Zd ZdZdS )ÚAppRegistryNotReadyz-The django.apps registry is not populated yetN)r   r   r   r   r	   r	   r	   r
   r      s   r   c               @   s   e Zd ZdZdZdS )ÚObjectDoesNotExistz#The requested object does not existTN)r   r   r   r   Zsilent_variable_failurer	   r	   r	   r
   r      s   r   c               @   s   e Zd ZdZdS )ÚMultipleObjectsReturnedz?The query returned multiple objects when only one was expected.N)r   r   r   r   r	   r	   r	   r
   r      s   r   c               @   s   e Zd ZdZdS )ÚSuspiciousOperationz!The user did something suspiciousN)r   r   r   r   r	   r	   r	   r
   r       s   r   c               @   s   e Zd ZdZdS )ÚSuspiciousMultipartFormz+Suspect MIME request in multipart form dataN)r   r   r   r   r	   r	   r	   r
   r   $   s   r   c               @   s   e Zd ZdZdS )ÚSuspiciousFileOperationz/A Suspicious filesystem operation was attemptedN)r   r   r   r   r	   r	   r	   r
   r   )   s   r   c               @   s   e Zd ZdZdS )ÚDisallowedHostz'HTTP_HOST header contains invalid valueN)r   r   r   r   r	   r	   r	   r
   r   .   s   r   c               @   s   e Zd ZdZdS )ÚDisallowedRedirectz&Redirect to scheme not in allowed listN)r   r   r   r   r	   r	   r	   r
   r   3   s   r   c               @   s   e Zd ZdZdS )ÚTooManyFieldsSentze
    The number of fields in a POST request exceeded
    settings.DATA_UPLOAD_MAX_NUMBER_FIELDS.
    N)r   r   r   r   r	   r	   r	   r
   r   8   s   r   c               @   s   e Zd ZdZdS )ÚRequestDataTooBigzq
    The size of the request (excluding any file uploads) exceeded
    settings.DATA_UPLOAD_MAX_MEMORY_SIZE.
    N)r   r   r   r   r	   r	   r	   r
   r   @   s   r   c               @   s   e Zd ZdZdS )ÚPermissionDeniedz+The user did not have permission to do thatN)r   r   r   r   r	   r	   r	   r
   r   H   s   r   c               @   s   e Zd ZdZdS )ÚViewDoesNotExistz!The requested view does not existN)r   r   r   r   r	   r	   r	   r
   r   M   s   r   c               @   s   e Zd ZdZdS )ÚMiddlewareNotUsedz8This middleware is not used in this server configurationN)r   r   r   r   r	   r	   r	   r
   r   R   s   r   c               @   s   e Zd ZdZdS )ÚImproperlyConfiguredz'Django is somehow improperly configuredN)r   r   r   r   r	   r	   r	   r
   r   W   s   r   c               @   s   e Zd ZdZdS )Ú
FieldErrorz(Some kind of problem with a model field.N)r   r   r   r   r	   r	   r	   r
   r   \   s   r   Ú__all__c                   sZ   e Zd ZdZd‡ fdd„	Zedd„ ƒZedd„ ƒZd	d
„ Zdd„ Z	dd„ Z
dd„ Z‡  ZS )ÚValidationErrorzAn error while validating data.Nc                s.  t t| ƒj|||ƒ t|tƒrbt|dƒr0|j}n2t|tjr>dndƒsL|j}n|j	|j
|j  }}}t|tƒr¨i | _x¶|jƒ D ]&\}}t|tƒs–t|ƒ}|j| j|< q|W n‚t|tƒrg | _xn|D ]J}t|tƒsÖt|ƒ}t|dƒ rü| jjt|jjƒ g ƒƒ qÀ| jj|jƒ qÀW n|| _	|| _
|| _| g| _dS )aÒ  
        The `message` argument can be a single error, a list of errors, or a
        dictionary that maps field names to lists of errors. What we define as
        an "error" can be either a simple string or an instance of
        ValidationError with its message attribute set, and what we define as
        list or dictionary can be an actual `list` or `dict` or an instance
        of ValidationError with its `error_list` or `error_dict` attribute set.
        Ú
error_dictÚmessageÚcodeN)Úsuperr   Ú__init__Ú
isinstanceÚhasattrr   r   ÚPY3Ú
error_listr   r   ÚparamsÚdictÚitemsÚlistÚextendÚsumÚvalues)Úselfr   r   r&   ÚfieldÚmessages)Ú	__class__r	   r
   r!   f   s2    





zValidationError.__init__c             C   s   t | dƒ t| ƒS )Nr   )Úgetattrr'   )r-   r	   r	   r
   Úmessage_dict–   s    
zValidationError.message_dictc             C   s$   t | dƒrtt| ƒjƒ g ƒS t| ƒS )Nr   )r#   r+   r'   r,   r)   )r-   r	   r	   r
   r/   ž   s    
zValidationError.messagesc             C   sN   t | dƒr6x>| jjƒ D ]\}}|j|g ƒj|ƒ qW n|jtg ƒj| jƒ |S )Nr   )r#   r   r(   Ú
setdefaultr*   ÚNON_FIELD_ERRORSr%   )r-   r   r.   r%   r	   r	   r
   Úupdate_error_dict¤   s
    
z!ValidationError.update_error_dictc             c   sj   t | dƒr6xZ| jjƒ D ]\}}|tt|ƒƒfV  qW n0x.| jD ]$}|j}|jrX||j; }t|ƒV  q>W d S )Nr   )	r#   r   r(   r)   r   r%   r   r&   r   )r-   r.   ÚerrorsÚerrorr   r	   r	   r
   Ú__iter__¬   s    

zValidationError.__iter__c             C   s"   t | dƒrtt| ƒƒS tt| ƒƒS )Nr   )r#   Úreprr'   r)   )r-   r	   r	   r
   Ú__str__·   s    
zValidationError.__str__c             C   s   d|  S )NzValidationError(%s)r	   )r-   r	   r	   r
   Ú__repr__¼   s    zValidationError.__repr__)NN)r   r   r   r   r!   Úpropertyr2   r/   r5   r8   r:   r;   Ú__classcell__r	   r	   )r0   r
   r   d   s   0r   N)r   Zdjango.utilsr   Zdjango.utils.encodingr   Ú	Exceptionr   ÚRuntimeWarningr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r4   r   r	   r	   r	   r
   Ú<module>   s*   