
    Og                         d 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	Zd
 ZddZddZddZddZd Zd Zd Zy)zInterface utility functions
    )alsoProvides)
IInterface)getGlobalSiteManager)ComponentLookupError)queryUtility)CLASS_TYPESNc                 J   | s|j                   d|j                  } t        j                  |      st	        |t
              st        | d      y|.|j                  t              st        |d      t        ||       nt        }t               }|j                  ||| |       y)z@ Mark 'interface' as a named utilty providing 'iface_type'.
    .zis not an interface or classNzis not an interface type)
__module____name__r   
providedBy
isinstancer   	TypeErrorextendsr   r   registerUtility)id	interface
iface_typeinfogsms        S/var/www/djangounited/venv/lib/python3.12/site-packages/zope/component/interface.pyprovideInterfacer      s     !,,i.@.@A  +)[1B >??!!*-J(BCCY
+


 C	:r48    c                 8    t        |d      }|t        |      |S )z3Return interface or raise ComponentLookupError
    N)queryInterfacer   contextr   ifaces      r   getInterfacer   .   s%     2t$E}"2&&Lr   c                 $    t        t        | |      S )z$Return an interface or ``None``
    )r   r   )r   defaults     r   r   r   7   s     
B00r   c                 H    t        | ||      D cg c]  }|d   	 c}S c c}w )Interfaces search
       searchInterfaceUtilitiesr   search_stringbase
iface_utils       r   searchInterfacer+   =   1     %WmTBDjJqM D D D   c                 H    t        | ||      D cg c]  }|d   	 c}S c c}w )r#   r   r%   r'   s       r   searchInterfaceIdsr/   D   r,   r-   c                 P   t               }|j                  t              }|r?|j                         }|D cg c]$  }t	        |d         j                  |      dk\  r|& }}|r%|D cg c]  }|d   j                  |      r| }}|S |D cg c]  }| }}|S c c}w c c}w c c}w )Nr$   r   )r   getUtilitiesForr   lowergetInterfaceAllDocsfindisOrExtends)r   r(   r)   r   iface_utilitiesr*   ress          r   r&   r&   K   s    

 C))*5O%++-8G :*2:a=A#tM2a 8 & : : ,; 3jQ-++D1  3 3 J -<<jz<<J:3 =s   )B'B	B#c                    | j                   d| j                  }t        |      j                         t        | j                        j                         g}t        j                  |       rQt        |       D ]C  }|j                  t        | j                  |      j                        j                                E dj                  |      S )Nr
   
)r   r   strr2   __doc__r   r   sortedappendgetDescriptionForjoin)r   iface_iddocsnames       r   r3   r3   \   s    "--y/A/ABHM!	!!"((*,D Y'9% 	HDKKI//5==>DDFH	H 99T?r   c                 *    |dk(  ry t        | |      }|S )NNone)r   r   s      r   nameToInterfacerE   i   s    	V|"%ELr   c                     |yt        | |      }|D cg c]"  }||k(  r|j                  d|j                  $ }}|s|j                  dz   |j                  z   S t        |      dk(  s
J d|z         |d   S c c}w )NrD   )r)   r
   r$   zAmbiguous interface names: %sr   )r+   r   r   len)r   r   itemsr   idss        r   interfaceToNamerJ   o   s     G)4E"y  &&7 "C "  ##c)I,>,>>>s8q=?9C??=q6M"s   'A9)N )N)NN)r;   zope.interfacer   zope.interface.interfacesr   zope.component.globalregistryr   zope.component.interfacesr   zope.component._apir   zope.component._compatr   r   r   r   r+   r/   r&   r3   rE   rJ    r   r   <module>rS      sK    ' 0 > : , .9,1DD"
r   