ó
ÔËÞKc           @   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(   sW   Verify interface implementations

$Id: verify.py 110699 2010-04-09 08:16:17Z regebro $
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\ } } 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 | ƒ} nZ t | t ƒ rmt | j ƒ t	 k rmt | |  | ƒ } 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   im_funcR   t   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   s<    	"c         C   s   t  |  | | d d ƒS(   NR   R   (   R$   (   R   R   R   (    (    s9   /usr/lib/python2.7/dist-packages/zope/interface/verify.pyt   verifyClassb   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   verifyObjecte   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   h   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   	E