
    e                         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mZmZ ddgZefZddZd ZddZddZej                   e_         dZd Zy)z!Verify interface implementations
    N)FunctionType)
MethodType)BrokenImplementation)BrokenMethodImplementation)DoesNotImplement)Invalid)MultipleInvalid)
fromMethodfromFunctionMethodverifyObjectverifyClassc                 t   |dk(  r| j                   }n| j                  }g }|s# ||      s|j                  t        | |             | j	                  d      D ]  \  }}	 t        | ||||        |r t        |      dk(  r|d   t        | ||      y# t        $ r}|j                  |       Y d}~Zd}~ww xY w)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   )	implementedBy
providedByappendr   namesAndDescriptions_verify_elementr   lenr	   )	iface	candidate	tentativevtypetesterexcsnamedesces	            7/usr/lib/python3/dist-packages/zope/interface/verify.py_verifyr#   '   s    @ |$$!!DVI.$UI6700T0: 
d	E4y%@ t9>q'MeY55  	KKNN	s   B	B7B22B7c                    	 t        ||      }t        |t              sy t        j                  |      st        j                  |      ry t        |t              r4t        |t              r|dk(  rt        || |d      }nyt        || |      }njt        |t              r)t        |j                        t        u rt        || |      }n1t        |t              r|dk(  ry t        |      st!        |d|| |      y t#        |j%                         |j%                               }|rt!        |||| |      y # t        $ r% t        |t              s|dk(  rY y t	        | ||      w xY w)Nr   r   )r   imlevel)r   zimplementation is not a method)getattrAttributeError
isinstancer   r   inspectismethoddescriptor	isbuiltinr   typer   MethodTypes__func__r
   propertycallabler   	_incompatgetSignatureInfo)r   r   r    r   r   attrmethmesss           r"   r   r   ]   sV   ;y$' dF#!!$'7+<+<T+B 	$%i&5C<
  e$BD  e$7D
T;
'4==!\1$t,	D(	#
 	 ~,T3S-15)E E 	 T**,d.C.C.EFD(tT5)LL s  ;4(esl "5$	::;s   D2 2E E c                      t        | ||d      S )zF
    Verify that the *candidate* might correctly provide *iface*.
    r   r   r#   r   r   r   s      r"   r   r      s     5)Yc::    c                      t        | ||d      S )Nor7   r8   r9   s      r"   r   r      s    5)Yc::r:   z*implementation requires too many argumentsc                     t        |d         t        | d         kD  rt        S t        |d         t        | d         k  r|d   sy| d   r|d   sy| d   r|d   syy y )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)r>   implementeds     r"   r1   r1      sy    
 ;z"#c(:*>&??	[&	'#h|.D*E	EI&>+h"7A	;y#9B $:r:   )FN)F)__doc__r)   systypesr   r   zope.interface.exceptionsr   r   r   r   r	   zope.interface.interfacer
   r   r   __all__r-   r#   r   r   r   rB   r1    r:   r"   <module>rK      ss     
   : @ 6 - 5 E E  n4l>MD;;  <Cr:   