ó
2(Vc           @   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	 „ Z d d
 „ Z d „  Z d S(   s!   Verify interface implementations
iÿÿÿÿ(   t   BrokenImplementationt   DoesNotImplement(   t   BrokenMethodImplementation(   t   FunctionTypet
   MethodType(   t
   fromMethodt   fromFunctiont   MethodNi    c   
      C   sö  | d k r |  j  } n	 |  j } | rD | | ƒ rD t |  ƒ ‚ n  x«|  j d ƒ D]š\ } } y t | | ƒ } WnB t k
 r· t | t ƒ r¥ | d k r¥ qT n  t |  | ƒ ‚ n Xt | t ƒ sÍ qT n  t | t	 ƒ r4t
 j d d k rt | t ƒ rt | |  d | d d ƒ} q¯t | |  d | ƒ} n{ t | t ƒ rmt | j ƒ t	 k rmt | |  | ƒ } nB t | t ƒ rŽ| d k rŽqT n! t | ƒ sT t | d ƒ ‚ qT qT | j ƒ  } | j ƒ  } t | | ƒ }	 |	 rT t | |	 ƒ ‚ qT qT Wt S(   sÍ  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.
    t   ci   i    t   3t   namet   imlevels   Not a method(   t   implementedByt
   providedByR   t   namesAndDescriptionst   getattrt   AttributeErrort
   isinstanceR   R    R   t   syst   versiont   typeR   t   MethodTypest   __func__R   t   propertyt   callableR   t   getSignatureInfot	   _incompatt   True(
   t   ifacet	   candidatet	   tentativet   vtypet   testerR
   t   desct   attrt   metht   mess(    (    s9   /usr/lib/python2.7/dist-packages/zope/interface/verify.pyt   _verify   sB    	"c         C   s   t  |  | | d d ƒS(   NR   R   (   R%   (   R   R   R   (    (    s9   /usr/lib/python2.7/dist-packages/zope/interface/verify.pyt   verifyClasse   s    c         C   s   t  |  | | d d ƒS(   NR   t   o(   R%   (   R   R   R   (    (    s9   /usr/lib/python2.7/dist-packages/zope/interface/verify.pyt   verifyObjecth   s    c         C   s‰   t  | d ƒ t  |  d ƒ k r$ d St  | d ƒ t  |  d ƒ k  rS | d rS d S|  d rl | d rl d S|  d r… | d r… d Sd  S(	   Nt   requireds*   implementation requires too many argumentst
   positionalt   varargss-   implementation doesn't allow enough argumentst   kwargss0   implementation doesn't support keyword argumentss1   implementation doesn't support variable arguments(   t   len(   R)   t   implemented(    (    s9   /usr/lib/python2.7/dist-packages/zope/interface/verify.pyR   k   s      (   t   __doc__t   zope.interface.exceptionsR    R   R   t   typesR   R   t   zope.interface.interfaceR   R   R   R   R   t   NoneR%   R&   R(   R   (    (    (    s9   /usr/lib/python2.7/dist-packages/zope/interface/verify.pyt   <module>   s   	J