o
    Êó·iŒ"  ã                   @   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   ú_C:\Users\psant\Downloads\PAF backend\school\venv\Lib\site-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_default9   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   ÚtargetC   s   z_TargetInvalid.targetc                 C   s   | j }|| ju r
dS d|›�S )Nz	An objectzThe object )r    r   )r   r    r   r   r   Ú_str_subject[   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_descriptionb   s   ÿz_TargetInvalid._str_descriptionz: z	<unknown>Ú.c                 C   s   d  | j| j| j| j| j¡S )Nz{} {}{}{}{})Úformatr!   r"   Ú_str_conjunctionÚ_str_detailsÚ_str_trailerr   r   r   r   Ú__str__l   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   v   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   Z_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              	   C   s’   dd l }z|j}t}W n ty   |j}|j}Y nw z|| ƒ}W n ttfy0   t| ƒ Y S w z| j	}W n tyB   | j
}Y nw |||ƒ S r4   )ÚinspectÚ	signaturer1   ÚAttributeErrorÚ
getargspecÚformatargspecÚ
ValueErrorÚ	TypeErrorr2   r   r
   )Úimplr7   ÚsigZ	formatsigr.   r   r   r   Z__implementation_strÁ   s&   
þû

ÿz/BrokenMethodImplementation.__implementation_strc                 C   sl   |   | j| j¡}| j}|| jur"d|v r"| dd¡}||  |¡f }d t| jt	ƒr1t
| jƒ|¡S | j|¡S )NÚimplementationz%rz)The contract of {} is violated because {})r   Ú_IX_IMPLr   r6   ÚreplaceÚ/_BrokenMethodImplementation__implementation_strr$   r0   r5   r1   r2   )r   r>   Úmessager   r   r   r&   Ý   s   þþz'BrokenMethodImplementation._str_detailsN)r
   r   r   r   rA   r   r   r*   r5   r6   ÚstaticmethodrC   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|ƒ¡ d S r   )ÚsuperÚ__init__Útuple)r   r   r    Ú
exceptions©Ú	__class__r   r   rG   ø   s   zMultipleInvalid.__init__c                 C   r+   )Nr3   r-   r   r   r   r   rI   û   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   )r0   r   r&   Ústripr1   )Ú.0Úxr   r   r   Ú	<genexpr>  s
   € ÿ
ÿz/MultipleInvalid._str_details.<locals>.<genexpr>)ÚjoinrI   r   r   r   r   r&   ÿ   s   
þzMultipleInvalid._str_detailsú:Ú )r
   r   r   r   r   rG   r*   rI   r&   r%   r'   Ú__classcell__r   r   rJ   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L!