o ,W@sdZddlmZddlmZddlmZddlmZddl m Z ddl m Z dd d Z d d ZdddZdddZdddZdddZddZddZddZdS)zInterface utility functions ) alsoProvides) IInterface)getGlobalSiteManager)ComponentLookupError) queryUtility) CLASS_TYPESNcCs||s d|j|jf}t|st|tst|ddS|dur/|ts)t|dt||nt}t }| ||||dS)z@ Mark 'interface' as a named utilty providing 'iface_type'. %s.%szis not an interface or classNzis not an interface type) __module____name__r providedBy isinstancer TypeErrorextendsrrregisterUtility)id interface iface_typeinfogsmr:/usr/lib/python3/dist-packages/zope/component/interface.pyprovideInterfaces      rcCst|d}|dur t||S)z3Return interface or raise ComponentLookupError N)queryInterfacercontextrifacerrr getInterface.s rcCs tt||S)z$Return an interface or ``None`` )rr)rdefaultrrrr7s rcCddt|||DS)Interfaces search cSg|]}|dqSr.0 iface_utilrrr @z#searchInterface..searchInterfaceUtilitiesr search_stringbaserrrsearchInterface= r.cCr)r cSr!)rrr$rrrr'Gr(z&searchInterfaceIds..r)r+rrrsearchInterfaceIdsDr/r0csZt}|t}rfdd|D}r$fdd|D}|Sdd|D}|S)Ncs&g|]}t|ddkr|qS)r#r)getInterfaceAllDocsfindr$)r,rrr'Qs  z,searchInterfaceUtilities..csg|] }|dr|qSr") isOrExtendsr$r-rrr'Us  cSsg|]}|qSrrr$rrrr'Xs)rgetUtilitiesForrlower)rr,r-riface_utilitiesresr)r-r,rr*Ks r*cCsfd|j|jf}t|t|jg}t|r.t|D]}|t| |jqd |S)Nr  ) r r strr6__doc__rr sortedappendgetDescriptionForjoin)riface_iddocsnamerrrr1\s     r1cCs|dkrdSt||}|S)NNone)rrrrrnameToInterfaceis rDcs^durdSt|d}fdd|D}|sjdjSt|dks+Jd||dS) NrCr4cs$g|]}|krd|j|jfqS)r )r r )r%rrrrr'us z#interfaceToName...r#zAmbiguous interface names: %sr)r.r r len)rritemsidsrrErinterfaceToNameos  rJ)Nr)N)NN)r;zope.interfacerzope.interface.interfacesrzope.component.globalregistryrzope.component.interfacesrzope.component._apirzope.component._compatrrrrr.r0r*r1rDrJrrrrs