
    Ng                         d Z ddlm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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 eef      Zd Zd Zy)z!Verify interface implementations
    )print_functionN)FunctionType)
MethodType)PYPY2)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	            P/var/www/djangounited/venv/lib/python3.12/site-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              rJt        j                  d   dk\  r%t        |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*        rt-        |||      ry t%        |||| |      y # t        $ r% t        |t              s|dk(  rY y t	        | ||      w xY w)Nr   r      r   )r!   imlevel)r!   zimplementation is not a method)getattrAttributeError
isinstancer   r   inspectismethoddescriptor	isbuiltinr   sysversion_infotyper   MethodTypes__func__r   propertycallabler   	_incompatgetSignatureInfor   _pypy2_false_positive)r   r!   r"   r   r   attrmethmesss           r$   r   r   `   s~   ;y$' dF#!!$'7+<+<T+B 	$%A!#
9d(CQT
  e$()+D  e$7D
T;
'4==!\1$t,	D(	#
 	 ~,T3S-15)E E 	 T**,d.C.C.EFD*4EB(tT5)LL u  ;4(esl "5$	::;s   E F
<F
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or=   r>   r?   s      r$   r   r      s    5)Yc::r@   z*implementation requires too many argumentsc                 ~    | t         vryt        t              j                         }|dk(  r|n
t	        |      }||v ryy)NFr   T)_KNOWN_PYPY2_FALSE_POSITIVESvars__builtins__valuesr1   )msgr   r   known_builtin_typescandidate_types        r$   r8   r8      sD     ..|,335"'3,YDON,,r@   c                     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)rL   implementeds     r$   r6   r6      sy    
 ;z"#c(:*>&??	[&	'#h|.D*E	EI&>+h"7A	;y#9B $:r@   )FN)F)__doc__
__future__r   r,   r/   typesr   r   zope.interface._compatr   zope.interface.exceptionsr   r   r	   r
   r   zope.interface.interfacer   r   r   __all__r2   r%   r   r   r   rP   	frozensetrD   r8   r6    r@   r$   <module>r[      s    %  
   ( : @ 6 - 5 E E  n4lAMJ;;  <(*   
.Cr@   