o k`&@sddlZgdZddZGdddeZGdddeZGd d d eeZGd d d eZ Gd dde Z Gddde Z Gdddee dZejZGdddeZdS)N) ComponentExtensionPoint implements Interface TracBaseError TracErrorTracValueErrorcCs|S)zTNo-op translation marker, inlined here to avoid importing from `trac.util`. )stringr r +/usr/lib/python3/dist-packages/trac/core.pyN_sr c@seZdZdZedZdS)rz.Base class for all exceptions defined in Trac.z Trac ErrorN)__name__ __module__ __qualname____doc__r titler r r r r s rcs<eZdZdZd fdd ZeddddZd d ZZS) rz&Standard exception for errors in Trac.NFcs8ddlm}t|||_|p||j|_||_dS)aIf the `message` contains a `p` or `div` element it will be rendered directly. Use the `message` class on the `p` or `div` element to style as a red box. Otherwise, the message should be plain text or contain only inline elements and will be wrapped in a `p` element and rendered in a red box. If title is given, it will be displayed as the large header above the error message. r)gettextN)trac.util.translationrsuper__init___messagershow_traceback)selfmessagerrr __class__r r r)s  zTracError.__init__cCs|jS)N)rrr r r 9szTracError.cCs t|d|S)Nr)setattr)rvr r r r:s cCsddlm}||jS)Nr) to_unicode)trac.util.textr r)rr r r r __str__<s  zTracError.__str__)NF) r rrrrpropertyrr" __classcell__r r rr r&src@eZdZdZdS)rzRaised when a function or operator receives an argument that is the correct type, but inappropriate value. :since: 1.2.1 Nr rrrr r r r rArc@r%)rz1Marker base class for extension point interfaces.Nr&r r r r rIr'rc@s(eZdZdZddZddZddZdS) rz0Marker class for extension points in components.cCs.t||j||_d|jj|jjf|_dS)zCreate the extension point. :param interface: the `Interface` subclass that defines the protocol for the extension point z*List of components that implement `~%s.%s`N)r#r extensions interfacerr r)rr)r r r rPs  zExtensionPoint.__init__cs0tj|jd}fdd|D}dd|DS)zeReturn a list of components that declare to implement the extension point interface. r csg|]}j|qSr )compmgr).0cls componentr r `sz-ExtensionPoint.extensions..cSsg|]}|r|qSr r )r+cr r r r/as) ComponentMeta _registrygetr))rr.classes componentsr r-r r([szExtensionPoint.extensionscCs d|jjS)z7Return a textual representation of the extension point.z)r)r rr r r __repr__cs zExtensionPoint.__repr__N)r rrrrr(r6r r r r rMs  rc@s4eZdZdZgZiZddZddZeddZ dS) r1z^Meta class for components. Takes care of component and extension point registration. c Cs~t||||}|dkr|S|dr|Stj|tj}|jD]}|jddD]}| |g}||vr;||q*q!|S)zCreate the component class.rabstract _implementsr ) type__new__r3r1 _componentsappendr2__mro____dict__ setdefault) mcsnamebasesd new_classregistryr,r)r4r r r r:ps     zComponentMeta.__new__cOst|tr||}||_|j|i||St|dkr$t|dts(Jd|d}|j|}|durL||}||_| ||||j|<|S)zReturn an existing instance of the component if it has already been activated, otherwise create a new instance. rz2First argument must be a ComponentManager instanceN) issubclassComponentManagerr:r*rlen isinstancer5r3component_activated)r,argskwargsrr*r r r __call__s"      zComponentMeta.__call__c Cstz|j|Wn tyYnw|jD]"}|jddD]}|j|}z||Wqty6YqwqdS)z%Remove a component from the registry.r8r N)r;remove ValueErrorr=r>r3r2)r,r.class_r) implementersr r r deregisters    zComponentMeta.deregisterN) r rrrr;r2r:rN classmethodrSr r r r r1hsr1c@s$eZdZdZeddZddZdS)rzBase class for components. Every component can declare what extension points it provides, as well as what extension points of other components it extends. cGs@td}|j}||jurd|vsJd|dg|dS)zCan be used in the class definition of `Component` subclasses to declare the extension points that are extended. rFrz3implements() can only be used in a class definitionr8N)sys _getframef_locals f_globalsr?extend) interfacesframelocals_r r r rs zComponent.implementscCsd|jj|jjfS)z1Return a textual representation of the component.z)rrr rr r r r6szComponent.__repr__N)r rrr staticmethodrr6r r r r rs   r) metaclassc@sPeZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ dS)rHz8The component manager keeps a pool of active components.cCs*i|_i|_t|tr||j|j<dSdS)z!Initialize the component manager.N)r5enabledrJrrrr r r rs  zComponentManager.__init__cCs ||jvS)zKReturn whether the given class is in the list of active components.)r5rr,r r r __contains__s zComponentManager.__contains__c Cs|||sdS|j|}|ssK