3 ,W@sdZddlmZddlmZddlmZddlmZddl m Z ddl m Z dd d Z d d ZdddZdddZdddZd ddZddZddZddZdS)!zInterface utility functions ) alsoProvides) IInterface)getGlobalSiteManager)ComponentLookupError) queryUtility) CLASS_TYPESNcCs||sd|j|jf}tj|s6t|ts2t|ddS|dk r^|jtsRt|dt||nt}t }|j ||||dS)z@ Mark 'interface' as a named utilty providing 'iface_type'. z%s.%szis not an interface or classNzis not an interface type) __module____name__r providedBy isinstancer TypeErrorZextendsrrZregisterUtility)id interfaceZ iface_typeinfogsmr/usr/lib/python3.6/interface.pyprovideInterfaces      rcCst|d}|dkrt||S)z3Return interface or raise ComponentLookupError N)queryInterfacer)contextrifacerrr getInterface.s rcCs tt||S)z$Return an interface or ``None`` )rr)rdefaultrrrr7srcCsddt|||DS)zInterfaces search cSsg|] }|dqS)r).0 iface_utilrrr @sz#searchInterface..)searchInterfaceUtilities)r search_stringbaserrrsearchInterface=sr!cCsddt|||DS)zInterfaces search cSsg|] }|dqS)rr)rrrrrrGsz&searchInterfaceIds..)r)rrr rrrsearchInterfaceIdsDsr"csXt}|jt}r.jfdd|D}rFfdd|D}ndd|D}|S)Ncs&g|]}t|djdkr|qS)rr)getInterfaceAllDocsfind)rr)rrrrQs z,searchInterfaceUtilities..csg|]}|djr|qS)r)Z isOrExtends)rr)r rrrUscSsg|]}|qSrr)rrrrrrXs)rZgetUtilitiesForrlower)rrr rZiface_utilitiesresr)r rrrKs rcCsjd|j|jf}t|jt|jjg}tj|r`x*t|D]}|jt|j |jjq>Wdj |S)Nz%s.%s ) r r strr%__doc__rr sortedappendZgetDescriptionForjoin)rZiface_idZdocsnamerrrr#\s  r#cCs|dkr dSt||}|S)NNone)r)rrrrrrnameToInterfaceis r/csFdkr dSt|d}fdd|D}|s>jdjS|dS)Nr.)r cs$g|]}|krd|j|jfqS)z%s.%s)r r )rr)rrrrusz#interfaceToName...r)r!r r )rritemsZidsr)rrinterfaceToNameos  r2)Nr)N)NN)NN)NN)r)Zzope.interfacerZzope.interface.interfacesrZzope.component.globalregistryrZzope.component.interfacesrZzope.component._apirZzope.component._compatrrrrr!r"rr#r/r2rrrrs