o
    $x`Ã!  ã                   @   s�   d Z g d¢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S )zInterface-specific exceptions
)ÚInvalidÚDoesNotImplementÚBrokenImplementationÚBrokenMethodImplementationÚMultipleInvalidÚBadImplementsÚInvalidInterfacec                   @   ó   e Zd ZdZdS )r   z A specification is violated
    N©Ú__name__Ú
__module__Ú__qualname__Ú__doc__© r   r   ú;/usr/lib/python3/dist-packages/zope/interface/exceptions.pyr      ó    r   c                   @   sj   e Zd ZdZdZeZdZddd„Ze	dd„ ƒZ
e	d	d
„ ƒZe	dd„ ƒZe	dd„ ƒZdZdZdZdd„ ZdS )Ú_TargetInvalidé    é   z<Not Given>Nc                 C   s&   z| j | W S  | jy   | Y S w ©N)ÚargsÚ_NOT_GIVEN_CATCH)ÚselfÚixÚdefaultr   r   r   Ú_get_arg_or_default8   s
   ÿz"_TargetInvalid._get_arg_or_defaultc                 C   s   |   | j¡S r   )r   Ú_IX_INTERFACE©r   r   r   r   Ú	interface>   s   z_TargetInvalid.interfacec                 C   s   |   | j| j¡S r   )r   Ú
_IX_TARGETÚ
_NOT_GIVENr   r   r   r   ÚtargetB   s   z_TargetInvalid.targetc                 C   s   | j }|| ju r
dS d|f S )Nz	An objectzThe object %r)r    r   )r   r    r   r   r   Ú_str_subjectZ   s   

z_TargetInvalid._str_subjectc                 C   s   d| j pd S )Nz$has failed to implement interface %sz	<Unknown>)r   r   r   r   r   Ú_str_descriptiona   s   ÿz_TargetInvalid._str_descriptionz: z	<unknown>Ú.c                 C   s   d| j | j| j| j| jf S )Nz%s %s%s%s%s)r!   r"   Ú_str_conjunctionÚ_str_detailsÚ_str_trailerr   r   r   r   Ú__str__k   s   ûz_TargetInvalid.__str__r   )r
   r   r   r   r   Ú
IndexErrorr   r   r   Úpropertyr   r    r!   r"   r$   r%   r&   r'   r   r   r   r   r   "   s$    




r   c                   @   s   e Zd ZdZdZdS )r   a  
    DoesNotImplement(interface[, target])

    The *target* (optional) does not implement the *interface*.

    .. versionchanged:: 5.0.0
       Add the *target* argument and attribute, and change the resulting
       string value of this object accordingly.
    z.Does not declaratively implement the interfaceN)r
   r   r   r   r%   r   r   r   r   r   u   s    
r   c                   @   s:   e Zd ZdZejd Zed Zedd„ ƒZ	edd„ ƒZ
dS )r   a[  
    BrokenImplementation(interface, name[, target])

    The *target* (optional) is missing the attribute *name*.

    .. versionchanged:: 5.0.0
       Add the *target* argument and attribute, and change the resulting
       string value of this object accordingly.

       The *name* can either be a simple string or a ``Attribute`` object.
    r   c                 C   ó
   | j d S ©Nr   ©r   r   r   r   r   Úname“   ó   
zBrokenImplementation.namec                 C   s"   dt | jtƒrt| jƒ S | j S )Nz!The %s attribute was not provided)Ú
isinstancer-   ÚstrÚreprr   r   r   r   r%   —   s
   ÿÿz!BrokenImplementation._str_detailsN)r
   r   r   r   r   r   Ú_IX_NAMEr   r)   r-   r%   r   r   r   r   r   ƒ   s    

r   c                   @   sT   e Zd ZdZdZed Zed Zedd„ ƒZedd„ ƒZ	e
dd	„ ƒZed
d„ ƒZdS )r   a¡  
    BrokenMethodImplementation(method, message[, implementation, interface, target])

    The *target* (optional) has a *method* in *implementation* that violates
    its contract in a way described by *mess*.

    .. versionchanged:: 5.0.0
       Add the *interface* and *target* argument and attribute,
       and change the resulting string value of this object accordingly.

       The *method* can either be a simple string or a ``Method`` object.

    .. versionchanged:: 5.0.0
       If *implementation* is given, then the *message* will have the
       string "implementation" replaced with an short but informative
       representation of *implementation*.

    é   r   c                 C   r*   )Nr   r,   r   r   r   r   Úmethod¶   r.   z!BrokenMethodImplementation.methodc                 C   r*   r+   r,   r   r   r   r   Úmessº   r.   zBrokenMethodImplementation.messc              	      sž   dd l }z|j}t}W n ty    |j}|j‰ ‡ fdd„}Y nw z|| ƒ}W n ttfy6   t| ƒ Y S w z| j	}W n tyH   | j
}Y nw |||ƒ S )Nr   c                    s   ˆ | Ž S r   r   )Úsig©Úfr   r   Ú<lambda>É   s    zABrokenMethodImplementation.__implementation_str.<locals>.<lambda>)ÚinspectÚ	signaturer0   ÚAttributeErrorÚ
getargspecÚformatargspecÚ
ValueErrorÚ	TypeErrorr1   r   r
   )Úimplr:   r6   Ú	formatsigr-   r   r7   r   Ú__implementation_str¾   s(   ýû

ÿz/BrokenMethodImplementation.__implementation_strc                 C   sn   |   | j| j¡}| j}|| jur"d|v r"| dd¡}||  |¡f }dt| jtƒr1t	| jƒ|f S | j|f S )NÚimplementationz%rz)The contract of %s is violated because %s)
r   Ú_IX_IMPLr   r5   ÚreplaceÚ/_BrokenMethodImplementation__implementation_strr/   r4   r0   r1   )r   rA   Úmessager   r   r   r%   Û   s   þþz'BrokenMethodImplementation._str_detailsN)r
   r   r   r   rE   r   r   r)   r4   r5   ÚstaticmethodrG   r%   r   r   r   r   r   ž   s    


r   c                       sD   e Zd ZdZdZ‡ fdd„Zedd„ ƒZedd„ ƒZd	Z	d
Z
‡  ZS )r   zÏ
    The *target* has failed to implement the *interface* in
    multiple ways.

    The failures are described by *exceptions*, a collection of
    other `Invalid` instances.

    .. versionadded:: 5.0
    r   c                    s   t t| ƒ ||t|ƒ¡ d S r   )Úsuperr   Ú__init__Útuple)r   r   r    Ú
exceptions©Ú	__class__r   r   rK   ö   s   zMultipleInvalid.__init__c                 C   r*   )Nr3   r,   r   r   r   r   rM   ù   r.   zMultipleInvalid.exceptionsc                 C   s   dd  dd„ | jD ƒ¡ S )Nz
    c                 s   s,   � | ]}t |tƒr|j ¡ nt|ƒV  qd S r   )r/   r   r%   Ústripr0   )Ú.0Úxr   r   r   Ú	<genexpr>  s
   € ÿ
ÿz/MultipleInvalid._str_details.<locals>.<genexpr>)ÚjoinrM   r   r   r   r   r%   ý   s   
þzMultipleInvalid._str_detailsú:Ú )r
   r   r   r   r   rK   r)   rM   r%   r$   r&   Ú__classcell__r   r   rN   r   r   é   s    


r   c                   @   r   )r   z'The interface has invalid contents
    Nr	   r   r   r   r   r   
  r   r   c                   @   r   )r   zŽAn implementation assertion is invalid

    because it doesn't contain an interface or a sequence of valid
    implementation assertions.
    Nr	   r   r   r   r   r     r   r   N)r   Ú__all__Ú	Exceptionr   r   r   r   r   r   r   r@   r   r   r   r   r   Ú<module>   s   SK!