o
    Êó·iv  ã                   @   sØ   d Z ddlZddlZddlmZ ddlmZ ddlmZ ddlmZ ddlm	Z	 ddlm
Z
 dd	lmZ dd
lmZ ddlmZ ddlmZ ddgZefZddd„Zdd„ Zddd„Zddd„Zej e_ dZdd„ ZdS )z!Verify interface implementations
é    N)ÚFunctionType)Ú
MethodType)ÚBrokenImplementation)ÚBrokenMethodImplementation)ÚDoesNotImplement)ÚInvalid)ÚMultipleInvalid)ÚMethod)ÚfromFunction)Ú
fromMethodÚverifyObjectÚverifyClassFc           	      C   s¶   |dkr| j }n| j}g }|s||ƒs| t| |ƒ¡ | jdd�D ]%\}}z
t| ||||ƒ W q! tyF } z| |¡ W Y d}~q!d}~ww |rYt|ƒdkrS|d ‚t| ||ƒ‚dS )a¤  
    Verify that *candidate* might correctly provide *iface*.

    This involves:

    - Making sure the candidate claims that it provides the
      interface using ``iface.providedBy`` (unless *tentative* is `True`, in
      which case this step is skipped). This means that the candidate's class
      declares that it `implements <zope.interface.implementer>` the
      interface, or the candidate itself declares that it `provides
      <zope.interface.provider>`
      the interface

    - Making sure the candidate defines all the necessary methods

    - Making sure the methods have the correct signature (to the
      extent possible)

    - Making sure the candidate defines all the necessary attributes

    :return bool: Returns a true value if everything that could be
       checked passed.
    :raises zope.interface.Invalid: If any of the previous
       conditions does not hold.

    .. versionchanged:: 5.0
        If multiple methods or attributes are invalid, all such errors
        are collected and reported. Previously, only the first error was
        reported.  As a special case, if only one such error is present, it is
        raised alone, like before.
    ÚcT)ÚallNé   r   )	ZimplementedByZ
providedByÚappendr   ZnamesAndDescriptionsÚ_verify_elementr   Úlenr   )	ÚifaceÚ	candidateÚ	tentativeÚvtypeÚtesterZexcsÚnameÚdescÚe© r   ú[C:\Users\psant\Downloads\PAF backend\school\venv\Lib\site-packages\zope/interface/verify.pyÚ_verify)   s$   !€ÿr   c                 C   s(  zt ||ƒ}W n ty    t|tƒs|dkrY d S t| ||ƒ‚w t|tƒs(d S t |¡s2t |¡r4d S t|tƒrSt|t	ƒrK|dkrKt
|| |dd�}n4t
|| |d�}n,t|tƒrft	|jƒtu rft|| |ƒ}nt|tƒrq|dkrqd S t|ƒs}t|d|| |ƒ‚d S t| ¡ | ¡ ƒ}|r’t|||| |ƒ‚d S )Nr   r   )r   Zimlevel)r   zimplementation is not a method)ÚgetattrÚAttributeErrorÚ
isinstancer	   r   ÚinspectÚismethoddescriptorÚ	isbuiltinr   Útyper
   ÚMethodTypesÚ__func__r   ÚpropertyÚcallabler   Ú	_incompatZgetSignatureInfo)r   r   r   r   r   ÚattrÚmethZmessr   r   r   r   a   sF   ø


ÿþû	ÿr   c                 C   ó   t | ||dd�S )zF
    Verify that the *candidate* might correctly provide *iface*.
    r   ©r   N©r   ©r   r   r   r   r   r   r   ¯   s   c                 C   r-   )NÚor.   r/   r0   r   r   r   r   ¶   s   z*implementation requires too many argumentsc                 C   sp   t |d ƒt | d ƒkrtS t |d ƒt | d ƒk r |d s dS | d r*|d s*dS | d r4|d s6dS d S d S )NÚrequiredÚ
positionalÚvarargsz-implementation doesn't allow enough argumentsÚkwargsz0implementation doesn't support keyword argumentsz1implementation doesn't support variable arguments)r   Ú_MSG_TOO_MANY)r2   Zimplementedr   r   r   r*   ¿   s   ÿþÿr*   )FN)F)Ú__doc__r"   ÚsysÚtypesr   r   Zzope.interface.exceptionsr   r   r   r   r   Zzope.interface.interfacer	   r
   r   Ú__all__r&   r   r   r   r   r6   r*   r   r   r   r   Ú<module>   s0   þ
8
N
