U
    
W[;"                     @   s  d Z ddlmZmZ ddlmZ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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 d0d1 d1eZG d2d3 d3eZG d4d5 d5eZ G d6d7 d7eZ!G d8d9 d9eZ"G d:d; d;eZ#G d<d= d=eZ$G d>d? d?eZ%G d@dA dAe%Z&G dBdC dCe&Z'G dDdE dEe&Z(G dFdG dGeZ)G dHdI dIeZ*G dJdK dKeZ+G dLdM dMeZ,G dNdO dOe,Z-G dPdQ dQe,Z.G dRdS dSe,Z/G dTdU dUe,Z0G dVdW dWe,Z1dXS )Yz 
Exceptions in L{twisted.mail}.
    )absolute_importdivision)_PY3unicodec                   @   s   e Zd ZdS )IMAP4ExceptionN__name__
__module____qualname__ r   r   6/usr/lib/python3/dist-packages/twisted/mail/_except.pyr      s   r   c                   @   s   e Zd ZdS )IllegalClientResponseNr   r   r   r   r   r      s   r   c                   @   s   e Zd ZdS )IllegalOperationNr   r   r   r   r   r      s   r   c                   @   s   e Zd ZdS )IllegalMailboxEncodingNr   r   r   r   r   r      s   r   c                   @   s   e Zd ZdS )MailboxExceptionNr   r   r   r   r   r   !   s   r   c                   @   s   e Zd Zdd ZdS )MailboxCollisionc                 C   s
   d| j  S )NzMailbox named %s already existsargsselfr   r   r   __str__'   s    zMailboxCollision.__str__Nr   r	   r
   r   r   r   r   r   r   &   s   r   c                   @   s   e Zd Zdd ZdS )NoSuchMailboxc                 C   s
   d| j  S )NzNo mailbox named %s existsr   r   r   r   r   r   -   s    zNoSuchMailbox.__str__Nr   r   r   r   r   r   ,   s   r   c                   @   s   e Zd Zdd ZdS )ReadOnlyMailboxc                 C   s   dS )NzMailbox open in read-only stater   r   r   r   r   r   3   s    zReadOnlyMailbox.__str__Nr   r   r   r   r   r   2   s   r   c                   @   s   e Zd ZdS )UnhandledResponseNr   r   r   r   r   r   7   s   r   c                   @   s   e Zd ZdS )NegativeResponseNr   r   r   r   r   r   <   s   r   c                   @   s   e Zd Zdd Zdd ZdS )NoSupportedAuthenticationc                 C   s   t | d || _|| _d S )Nz-No supported authentication schemes available)r   __init__serverSupportsclientSupports)r   r   r   r   r   r   r   B   s     z"NoSupportedAuthentication.__init__c                 C   s   t | d| j| jf  S )Nz(: Server supports %r, client supports %r)r   r   r   r   r   r   r   r   r   H   s
    
z!NoSupportedAuthentication.__str__Nr   r	   r
   r   r   r   r   r   r   r   A   s   r   c                   @   s   e Zd ZdS )IllegalServerResponseNr   r   r   r   r   r!   O   s   r!   c                   @   s   e Zd ZdS )IllegalIdentifierErrorNr   r   r   r   r   r"   T   s   r"   c                   @   s   e Zd ZdS )IllegalQueryErrorNr   r   r   r   r   r#   Y   s   r#   c                   @   s   e Zd ZdS )MismatchedNestingNr   r   r   r   r   r$   ^   s   r$   c                   @   s   e Zd ZdS )MismatchedQuotingNr   r   r   r   r   r%   c   s   r%   c                   @   s   e Zd ZdS )	SMTPErrorNr   r   r   r   r   r&   h   s   r&   c                   @   s*   e Zd ZdZd
ddZdd Zdd	 ZdS )SMTPClientErrorz,
    Base class for SMTP client errors.
    NFc                 C   s(   || _ || _|| _|| _|| _|| _dS )a  
        @param code: The SMTP response code associated with this error.

        @param resp: The string response associated with this error.

        @param log: A string log of the exchange leading up to and including
            the error.
        @type log: L{bytes}

        @param isFatal: A boolean indicating whether this connection can
            proceed or not. If True, the connection will be dropped.

        @param retry: A boolean indicating whether the delivery should be
            retried. If True and the factory indicates further retries are
            desirable, they will be attempted, otherwise the delivery will be
            failed.
        N)coderesplog	addressesisFatalretryr   r(   r)   r*   r+   r,   r-   r   r   r   r   q   s    zSMTPClientError.__init__c                 C   s   t r|  dS |  S d S )Nutf-8)r   	__bytes__decoder   r   r   r   r      s    zSMTPClientError.__str__c                 C   sv   | j dkrd| j | jg}n| jg}| jrB|| j |d t|D ] \}}t|trJ|d||< qJd	|S )Nr   z	{:03d} {}    r/      
)
r(   formatr)   r*   append	enumerate
isinstancer   encodejoin)r   resirr   r   r   r0      s    


zSMTPClientError.__bytes__)NNFF)r   r	   r
   __doc__r   r   r0   r   r   r   r   r'   m   s     
r'   c                   @   s   e Zd ZdZdS )ESMTPClientErrorz-
    Base class for ESMTP client errors.
    Nr   r	   r
   r=   r   r   r   r   r>      s   r>   c                   @   s   e Zd ZdZdS )EHLORequiredErrorz{
    The server does not support EHLO.

    This is considered a non-fatal error (the connection will not be dropped).
    Nr?   r   r   r   r   r@      s   r@   c                   @   s   e Zd ZdZdS )AUTHRequiredErrorz
    Authentication was required but the server does not support it.

    This is considered a non-fatal error (the connection will not be dropped).
    Nr?   r   r   r   r   rA      s   rA   c                   @   s   e Zd ZdZdS )TLSRequiredErrorz
    Transport security was required but the server does not support it.

    This is considered a non-fatal error (the connection will not be dropped).
    Nr?   r   r   r   r   rB      s   rB   c                   @   s   e Zd ZdZdS )AUTHDeclinedErrorz
    The server rejected our credentials.

    Either the username, password, or challenge response
    given to the server was rejected.

    This is considered a non-fatal error (the connection will not be
    dropped).
    Nr?   r   r   r   r   rC      s   rC   c                   @   s   e Zd ZdZdS )AuthenticationErrorz
    An error occurred while authenticating.

    Either the server rejected our request for authentication or the
    challenge received was malformed.

    This is considered a non-fatal error (the connection will not be
    dropped).
    Nr?   r   r   r   r   rD      s   rD   c                   @   s   e Zd ZdZdS )SMTPTLSErrorz
    An error occurred while negiotiating for transport security.

    This is considered a non-fatal error (the connection will not be dropped).
    Nr?   r   r   r   r   rE      s   rE   c                   @   s   e Zd ZdZdddZdS )SMTPConnectErrorzt
    Failed to connect to the mail exchange host.

    This is considered a fatal error.  A retry will be made.
    NTc              	   C   s   t | |||||| d S Nr'   r   r.   r   r   r   r      s    zSMTPConnectError.__init__)NNTTr   r	   r
   r=   r   r   r   r   r   rF      s     rF   c                   @   s   e Zd ZdZdddZdS )SMTPTimeoutErrorz
    Failed to receive a response from the server in the expected time period.

    This is considered a fatal error.  A retry will be made.
    NTc              	   C   s   t | |||||| d S rG   rH   r.   r   r   r   r      s    zSMTPTimeoutError.__init__)NNTTrI   r   r   r   r   rJ      s     rJ   c                   @   s   e Zd ZdZdddZdS )SMTPProtocolErrorzo
    The server sent a mangled response.

    This is considered a fatal error.  A retry will not be made.
    NTFc              	   C   s   t | |||||| d S rG   rH   r.   r   r   r   r     s    zSMTPProtocolError.__init__)NNTFrI   r   r   r   r   rK     s     rK   c                   @   s   e Zd ZdZdS )SMTPDeliveryErrorz=
    Indicates that a delivery attempt has had an error.
    Nr?   r   r   r   r   rL     s   rL   c                   @   s   e Zd Zdd Zdd ZdS )SMTPServerErrorc                 C   s   || _ || _d S rG   r(   r)   )r   r(   r)   r   r   r   r     s    zSMTPServerError.__init__c                 C   s   d| j | jf S )Nz%.3d %srN   r   r   r   r   r     s    zSMTPServerError.__str__Nr    r   r   r   r   rM     s   rM   c                   @   s   e Zd Zdd Zdd ZdS )SMTPAddressErrorc                 C   s(   ddl m} t| || ||| _d S )Nr   )Address)Ztwisted.mail.smtprP   rM   r   addr)r   rQ   r(   r)   rP   r   r   r   r   !  s    zSMTPAddressError.__init__c                 C   s   d| j | j| jf S )Nz%.3d <%s>... %s)r(   rQ   r)   r   r   r   r   r   (  s    zSMTPAddressError.__str__Nr    r   r   r   r   rO      s   rO   c                   @   s   e Zd ZdddZdS )SMTPBadRcpt&  $Cannot receive for specified addressc                 C   s   t | ||| d S rG   rO   r   r   rQ   r(   r)   r   r   r   r   .  s    zSMTPBadRcpt.__init__N)rS   rT   r   r	   r
   r   r   r   r   r   rR   -  s     rR   c                   @   s   e Zd ZdddZdS )SMTPBadSenderrS   Sender not acceptablec                 C   s   t | ||| d S rG   rU   rV   r   r   r   r   5  s    zSMTPBadSender.__init__N)rS   rY   rW   r   r   r   r   rX   4  s   rX   c                   @   s   e Zd ZdZdS )AddressErrorz 
    Parse error in address
    Nr?   r   r   r   r   rZ   :  s   rZ   c                   @   s   e Zd ZdZdS )	POP3Errorz)
    The base class for POP3 errors.
    Nr?   r   r   r   r   r[   @  s   r[   c                   @   s   e Zd ZdZdS )_POP3MessageDeletedzb
    An internal control-flow error which indicates that a deleted message was
    requested.
    Nr?   r   r   r   r   r\   H  s   r\   c                   @   s   e Zd ZdZdS )POP3ClientErrorzA
    The base class for all exceptions raised by POP3Client.
    Nr?   r   r   r   r   r]   P  s   r]   c                   @   s   e Zd ZdZdS ) InsecureAuthenticationDisallowedze
    An error indicating secure authentication was required but no mechanism
    could be found.
    Nr?   r   r   r   r   r^   W  s   r^   c                   @   s   e Zd ZdZdS )TLSErrorz
    An error indicating secure authentication was required but either the
    transport does not support TLS or no TLS context factory was supplied.
    Nr?   r   r   r   r   r_   _  s   r_   c                   @   s   e Zd ZdZdS )TLSNotSupportedErrorzi
    An error indicating secure authentication was required but the server does
    not support TLS.
    Nr?   r   r   r   r   r`   g  s   r`   c                   @   s   e Zd ZdZdddZdS )ServerErrorResponsez
    An error indicating that the server returned an error response to a
    request.

    @ivar consumer: See L{__init__}
    Nc                 C   s   t | | || _dS )a  
        @type reason: L{bytes}
        @param reason: The server response minus the status indicator.

        @type consumer: callable that takes L{object}
        @param consumer: The function meant to handle the values for a
            multi-line response.
        N)r]   r   consumer)r   reasonrb   r   r   r   r   v  s    	zServerErrorResponse.__init__)NrI   r   r   r   r   ra   o  s   ra   c                   @   s   e Zd ZdZdS )LineTooLongz
    An error indicating that the server sent a line which exceeded the
    maximum line length (L{LineOnlyReceiver.MAX_LENGTH}).
    Nr?   r   r   r   r   rd     s   rd   N)2r=   Z
__future__r   r   Ztwisted.python.compatr   r   	Exceptionr   r   r   r   r   r   r   r   r   r   r   r!   r"   r#   r$   r%   r&   r'   r>   r@   rA   rB   rC   rD   rE   rF   rJ   rK   rL   rM   rO   rR   rX   rZ   r[   r\   r]   r^   r_   r`   ra   rd   r   r   r   r   <module>   sX   5				