U
    ؒ]!                     @   s|   d Z ddlmZmZ ddlmZ ddlmZmZ ddlm	Z	m
Z
mZ ddlZefZdddZdd	d
ZdddZdd ZdS )z!Verify interface implementations
    )BrokenImplementationDoesNotImplement)BrokenMethodImplementation)FunctionType
MethodType)
fromMethodfromFunctionMethodNc           
   	   C   s`  |dkr| j }n| j}|s*||s*t| | dD ]$\}}zt||}W n4 tk
r   t|tsr|dkrrY q4t| |Y nX t|tsq4t|t	rt
jd dkrt|tr|dkrt|| |dd}nt|| |d}nXt|trt|jt	krt|| |}n.t|tr|dkrq4nt|s4t|dq4| }| }t||}	|	r4t||	q4dS )	a  Verify that 'candidate' might correctly implements 'iface'.

    This involves:

      o Making sure the candidate defines all the necessary methods

      o Making sure the methods have the correct signature

      o Making sure the candidate asserts that it implements the interface

    Note that this isn't the same as verifying that the class does
    implement the interface.

    If optional tentative is true, suppress the "is implemented by" test.
    c   r      )nameZimlevel)r   zNot a methodT)ZimplementedByZ
providedByr   ZnamesAndDescriptionsgetattrAttributeError
isinstancer	   r   r   sysversion_infotyper   MethodTypes__func__r   propertycallabler   ZgetSignatureInfo	_incompat)
iface	candidate	tentativevtypeZtesterr   ZdescattrmethZmess r   7/usr/lib/python3/dist-packages/zope/interface/verify.py_verify   sF    

 

r!   c                 C   s   t | ||ddS )Nr
   r   r!   r   r   r   r   r   r    verifyClassh   s    r%   c                 C   s   t | ||ddS )Nor"   r#   r$   r   r   r    verifyObjectk   s    r'   c                 C   sl   t |d t | d krdS t |d t | d k r@|d s@dS | d rT|d sTdS | d rh|d shdS d S )	Nrequiredz*implementation requires too many argumentsZ
positionalZvarargsz-implementation doesn't allow enough argumentskwargsz0implementation doesn't support keyword argumentsz1implementation doesn't support variable arguments)len)r(   Zimplementedr   r   r    r   n   s    r   )r   N)r   )r   )__doc__Zzope.interface.exceptionsr   r   r   typesr   r   Zzope.interface.interfacer   r   r	   r   r   r!   r%   r'   r   r   r   r   r    <module>   s   
M

