ó
Z´¢Tc           @   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/dist-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/dist-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/dist-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/dist-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/dist-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/dist-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/dist-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/dist-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/dist-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/dist-packages/zope/component/interface.pyt   <module>   s   				