U
    )Wjv  ã                   @   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 }|s6||ƒs6| t| |ƒ¡ | jdd�D ]J\}}zt| ||||ƒ W qB tk
rŠ } z| |¡ W 5 d}~X Y qBX qB|r²t|ƒdkr¦|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\hotstarbackend\school\venv38\Lib\site-packages\zope/interface/verify.pyÚ_verify)   s     !r   c                 C   s2  zt ||ƒ}W n8 tk
rF   t|tƒs6|dkr6Y d S t| ||ƒ‚Y nX t|tƒsVd S t |¡sjt |¡rnd S t|tƒr¬t|t	ƒrœ|dkrœt
|| |dd�}nt
|| |d�}nZt|tƒrÒt	|jƒtkrÒt|| |ƒ}n4t|tƒrè|dkrèd 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   sB    

ÿþ
û	r   c                 C   s   t | ||dd�S )zF
    Verify that the *candidate* might correctly provide *iface*.
    r   ©r   ©r   ©r   r   r   r   r   r   r   ¯   s    c                 C   s   t | ||dd�S )NÚor-   r.   r/   r   r   r   r   ¶   s    z*implementation requires too many argumentsc                 C   sl   t |d ƒt | d ƒkrtS t |d ƒt | d ƒk r@|d s@dS | d rT|d sTdS | d rh|d shd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)r1   Zimplementedr   r   r   r*   ¿   s    ÿþr*   )FN)F)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   r5   r*   r   r   r   r   Ú<module>   s.   þ
8N

