ó
6j/Qc           @   sÖ   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 d	  Z d
   Z d d  Z d d d  Z d d d  Z d d d  Z d   Z d   Z d   Z d S(   s   Interface utility functions
i˙˙˙˙(   t   alsoProvides(   t
   IInterface(   t   getGlobalSiteManager(   t   ComponentLookupError(   t   queryUtility(   t   CLASS_TYPESt    c         C   sı   |  s d | j  | j f }  n  t j |  sS t | t  sO t |  d   n  d S| d k	 r | j t  s t | d   n  t	 | |  n t } t
   } | j | | |  |  d S(   s@    Mark 'interface' as a named utilty providing 'iface_type'.
    s   %s.%ss   is not an interface or classNs   is not an interface type(   t
   __module__t   __name__R   t
   providedByt
   isinstanceR   t	   TypeErrort   Nonet   extendsR    R   t   registerUtility(   t   idt	   interfacet
   iface_typet   infot   gsm(    (    s<   /usr/lib/python2.7/site-packages/zope/component/interface.pyt   provideInterface   s    	c         C   s.   t  | d  } | d k r* t |   n  | S(   s3   Return interface or raise ComponentLookupError
    N(   t   queryInterfaceR   R   (   t   contextR   t   iface(    (    s<   /usr/lib/python2.7/site-packages/zope/component/interface.pyt   getInterface.   s    c         C   s   t  t |  |  S(   s$   Return an interface or ``None``
    (   R   R   (   R   t   default(    (    s<   /usr/lib/python2.7/site-packages/zope/component/interface.pyR   7   s    c         C   s'   g  t  |  | |  D] } | d ^ q S(   s   Interfaces search
    i   (   t   searchInterfaceUtilities(   R   t   search_stringt   baset
   iface_util(    (    s<   /usr/lib/python2.7/site-packages/zope/component/interface.pyt   searchInterface=   s    c         C   s'   g  t  |  | |  D] } | d ^ q S(   s   Interfaces search
    i    (   R   (   R   R   R   R   (    (    s<   /usr/lib/python2.7/site-packages/zope/component/interface.pyt   searchInterfaceIdsD   s    c         C   s·   t    } | j t  } | re | j   } g  | D]+ } t | d  j |  d k r1 | ^ q1 } n  | r g  | D] } | d j |  rr | ^ qr } n g  | D] } | ^ qĦ } | S(   Ni   i    (   R   t   getUtilitiesForR   t   lowert   getInterfaceAllDocst   findt   isOrExtends(   R   R   R   R   t   iface_utilitiesR   t   res(    (    s<   /usr/lib/python2.7/site-packages/zope/component/interface.pyR   K   s    	"c         C   s   d |  j  |  j f } t |  j   t |  j  j   g } t j |   r x< t |   D]+ } | j t |  j	 |  j  j    qY Wn  d j
 |  S(   Ns   %s.%ss   
(   R   R   t   strR!   t   __doc__R   R	   t   sortedt   appendt   getDescriptionFort   join(   R   t   iface_idt   docst   name(    (    s<   /usr/lib/python2.7/site-packages/zope/component/interface.pyR"   \   s    &c         C   s#   | d k r d  St |  |  } | S(   NR   (   R   R   (   R   R   R   (    (    s<   /usr/lib/python2.7/site-packages/zope/component/interface.pyt   nameToInterfacei   s    c         C   s   | d  k r d St |  d | } g  | D]( } | | k r) d | j | j f ^ q) } | so | j d | j St |  d k s t d |   | d S(   NR   R   s   %s.%st   .i   s   Ambiguous interface names: %si    (   R   R   R   R   t   lent   AssertionError(   R   R   t   itemsR   t   ids(    (    s<   /usr/lib/python2.7/site-packages/zope/component/interface.pyt   interfaceToNameo   s    
("N(   R(   t   zope.interfaceR    t   zope.interface.interfacesR   t   zope.component.globalregistryR   t   zope.component.interfacesR   t   zope.component._apiR   t   zope.component._compatR   R   R   R   R   R   R   R   R"   R0   R6   (    (    (    s<   /usr/lib/python2.7/site-packages/zope/component/interface.pyt   <module>   s   				