
    e!                         d Z g dZ G d de      Z G d de      Z G d de      Z G d d	e      Z G d
 de      Z G d de      Z G d de      Z	 G d de
      Zy)zInterface-specific exceptions
)InvalidDoesNotImplementBrokenImplementationBrokenMethodImplementationMultipleInvalidBadImplementsInvalidInterfacec                       e Zd ZdZy)r   z A specification is violated
    N__name__
__module____qualname____doc__     ;/usr/lib/python3/dist-packages/zope/interface/exceptions.pyr   r          r   r   c                   v    e Zd ZdZdZeZdZddZe	d        Z
e	d        Ze	d        Ze	d	        Zd
ZdZdZd Zy)_TargetInvalid       z<Not Given>Nc                 P    	 | j                   |   S # | j                  $ r |cY S w xY wN)args_NOT_GIVEN_CATCH)selfixdefaults      r   _get_arg_or_defaultz"_TargetInvalid._get_arg_or_default8   s/    	99R= $$ 	N	s    %%c                 8    | j                  | j                        S r   )r   _IX_INTERFACEr   s    r   	interfacez_TargetInvalid.interface>   s    ''(:(:;;r   c                 N    | j                  | j                  | j                        S r   )r   
_IX_TARGET
_NOT_GIVENr!   s    r   targetz_TargetInvalid.targetB   s    ''IIr   c                 Z    | j                   }|| j                  u rydj                  |      S )Nz	An objectzThe object {!r})r&   r%   format)r   r&   s     r   _str_subjectz_TargetInvalid._str_subjectZ   s+    T__$ ''//r   c                 (    d| j                   xs dz  S )Nz$has failed to implement interface %sz	<Unknown>)r"   r!   s    r   _str_descriptionz_TargetInvalid._str_descriptiona   s    5NN)k
 	
r   z: z	<unknown>.c                     dj                  | j                  | j                  | j                  | j                  | j
                        S )Nz{} {}{}{}{})r(   r)   r+   _str_conjunction_str_details_str_trailerr!   s    r   __str__z_TargetInvalid.__str__k   sB    ##!!!!
 	
r   r   )r   r   r   r    r$   
IndexErrorr   r%   r   propertyr"   r&   r)   r+   r.   r/   r0   r1   r   r   r   r   r   "   s     MJ "J < < J J. 0 0 
 

 LL
r   r   c                       e Zd ZdZdZy)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     DLr   r   c                   X    e Zd ZdZej
                  dz   Zedz   Zed        Z	ed        Z
y)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                      | j                   d   S Nr   r   r!   s    r   namezBrokenImplementation.name       yy|r   c                     dt        | j                  t              rt        | j                        z  S | j                  z  S )Nz!The %s attribute was not provided)
isinstancer9   strreprr!   s    r   r/   z!BrokenImplementation._str_details   s8    2)$))S9DO
 	
?Cyy
 	
r   N)r   r   r   r   r   r    _IX_NAMEr$   r3   r9   r/   r   r   r   r   r      sH    
 ++a/HAJ  
 
r   r   c                   h    e Zd ZdZdZedz   Zedz   Zed        Zed        Z	e
d        Zed        Zy)	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                      | j                   d   S )Nr   r8   r!   s    r   methodz!BrokenMethodImplementation.method   r:   r   c                      | j                   d   S r7   r8   r!   s    r   messzBrokenMethodImplementation.mess   r:   r   c                 B   dd l }	 |j                  }t        }	  ||       }	 | j                  }| ||      z   S # t        $ r  |j                  }|j
                  fd}Y Iw xY w# t        t        f$ r t        |       cY S w xY w# t        $ r | j                  }Y nw xY w)Nr   c                      |  S r   r   )sigfs    r   <lambda>zABrokenMethodImplementation.__implementation_str.<locals>.<lambda>   s    AsG r   )inspect	signaturer=   AttributeError
getargspecformatargspec
ValueError	TypeErrorr>   r   r   )implrK   rH   	formatsigr9   rI   s        @r   __implementation_strz/BrokenMethodImplementation.__implementation_str   s     		,##CI	d)C	!$$D in$$'  	,$$C%%A+I	, I& 	
 :	  	!==D	!s1   : A& B &A#"A#&BBBBc                 x   | j                  | j                  | j                        }| j                  }|| j                  ur+d|v r'|j	                  dd      }|| j                  |      fz  }dj                  t        | j                  t              rt        | j                        |      S | j                  |      S )Nimplementationz%rz)The contract of {} is violated because {})r   _IX_IMPLr%   rE   replace/_BrokenMethodImplementation__implementation_strr(   r<   rC   r=   r>   )r   rR   messages      r   r/   z'BrokenMethodImplementation._str_details   s    ''tG))t&+;w+Foo&6=G!:!:4!@ BBG:AA!+DKK!=D
 	
CG;;
 	
r   N)r   r   r   r   rW   r    r$   r3   rC   rE   staticmethodrY   r/   r   r   r   r   r      so    & HqLM"J    % %8 

 

r   r   c                   N     e Zd ZdZdZ fdZed        Zed        ZdZ	dZ
 x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                 :    t         |   ||t        |             y r   )super__init__tuple)r   r"   r&   
exceptions	__class__s       r   r_   zMultipleInvalid.__init__   s    FE*,=>r   c                      | j                   d   S )NrA   r8   r!   s    r   ra   zMultipleInvalid.exceptions   r:   r   c                 L    ddj                  d | j                  D              z   S )Nz
    c              3      K   | ]9  }t        |t              r|j                  j                         n
t	        |       ; y wr   )r<   r   r/   stripr=   ).0xs     r   	<genexpr>z/MultipleInvalid._str_details.<locals>.<genexpr>  s7      (
 '1N&CANN  "QO(
s   ?A)joinra   r!   s    r   r/   zMultipleInvalid._str_details   s-     (-- (
__(
 
 
 	
r   : )r   r   r   r   r   r_   r3   ra   r/   r.   r0   __classcell__)rb   s   @r   r   r      sJ     ?   
 
 Lr   r   c                       e Zd ZdZy)r   z'The interface has invalid contents
    Nr
   r   r   r   r   r   
  r   r   r   c                       e Zd ZdZy)r   zAn implementation assertion is invalid

    because it doesn't contain an interface or a sequence of valid
    implementation assertions.
    Nr
   r   r   r   r   r     s    r   r   N)r   __all__	Exceptionr   r   r   r   r   r   r   rQ   r   r   r   r   <module>rr      sz   
i 
P
W P
fD~ D
> 
6H
 H
Vn By I r   