HEX
Server: Apache
System: Linux pdx1-shared-a1-38 6.6.104-grsec-jammy+ #3 SMP Tue Sep 16 00:28:11 UTC 2025 x86_64
User: mmickelson (3396398)
PHP: 8.1.31
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/trac/__pycache__/core.cpython-310.pyc
o

�k�`�&�@s�ddlZgd�Zdd�ZGdd�de�ZGdd�de�ZGd	d
�d
ee�ZGdd�de�Z	Gd
d�de
�ZGdd�de�Z
Gdd�dee
d�ZejZGdd�de�ZdS)�N)�	Component�ExtensionPoint�
implements�	Interface�
TracBaseError�	TracError�TracValueErrorcCs|S)zTNo-op translation marker, inlined here to avoid importing from
    `trac.util`.
    �)�stringr	r	�+/usr/lib/python3/dist-packages/trac/core.py�N_src@seZdZdZed�ZdS)rz.Base class for all exceptions defined in Trac.z
Trac ErrorN)�__name__�
__module__�__qualname__�__doc__r�titler	r	r	rr srcs<eZdZdZd�fdd�	Zedd�dd��Zd	d
�Z�ZS)rz&Standard exception for errors in Trac.NFcs8ddlm}t��|�||_|p||j�|_||_dS)a�If 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.translationr�super�__init__�_messager�show_traceback)�self�messagerrr��	__class__r	rr)s


zTracError.__init__cCs|jS)N)r�rr	r	r�<lambda>9szTracError.<lambda>cCst|d|�S)Nr)�setattr)r�vr	r	rr:scCsddlm}||j�S)Nr)�
to_unicode)�trac.util.textr r)rr r	r	r�__str__<s
zTracError.__str__)NF)	r
rrrr�propertyrr"�
__classcell__r	r	rrr&s�rc@�eZdZdZdS)rz�Raised when a function or operator receives an argument that is
    the correct type, but inappropriate value.

    :since: 1.2.1
    N�r
rrrr	r	r	rrA�rc@r%)rz1Marker base class for extension point interfaces.Nr&r	r	r	rrIr'rc@s(eZdZdZdd�Zdd�Zdd�ZdS)	rz0Marker class for extension points in components.cCs.t�||j�||_d|jj|jjf|_dS)z�Create 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	rrPs

�zExtensionPoint.__init__cs0tj�|jd�}�fdd�|D�}dd�|D�S)zeReturn a list of components that declare to implement the
        extension point interface.
        r	csg|]}�j|�qSr	)�compmgr)�.0�cls��	componentr	r�
<listcomp>`sz-ExtensionPoint.extensions.<locals>.<listcomp>cSsg|]}|r|�qSr	r	)r+�cr	r	rr/as)�
ComponentMeta�	_registry�getr))rr.�classes�
componentsr	r-rr([szExtensionPoint.extensionscCsd|jjS)z7Return a textual representation of the extension point.z<ExtensionPoint %s>)r)r
rr	r	r�__repr__cszExtensionPoint.__repr__N)r
rrrrr(r6r	r	r	rrMs
rc@s4eZdZdZgZiZdd�Zdd�Zedd��Z	dS)	r1z^Meta class for components.

    Takes care of component and extension point registration.
    c	Cs~t�||||�}|dkr|S|�d�r|Stj�|�tj}|jD]}|j�dd�D]}|�	|g�}||vr;|�|�q*q!|S)zCreate the component class.r�abstract�_implementsr	)
�type�__new__r3r1�_components�appendr2�__mro__�__dict__�
setdefault)	�mcs�name�bases�d�	new_class�registryr,r)r4r	r	rr:ps


��zComponentMeta.__new__cOs�t|t�r|�|�}||_|j|i|��|St|�dkr$t|dt�s(Jd��|d}|j�|�}|durL|�|�}||_|�	|�|��||j|<|S)z�Return an existing instance of the component if it has
        already been activated, otherwise create a new instance.
        �rz2First argument must be a ComponentManager instanceN)
�
issubclass�ComponentManagerr:r*r�len�
isinstancer5r3�component_activated)r,�args�kwargsrr*r	r	r�__call__�s"

�


zComponentMeta.__call__c
Cstz|j�|�Wn	tyYnw|jD]"}|j�dd�D]}|j�|�}z|�|�Wqty6YqwqdS)z%Remove a component from the registry.r8r	N)r;�remove�
ValueErrorr=r>r3r2)r,r.�class_r)�implementersr	r	r�
deregister�s�
���zComponentMeta.deregisterN)
r
rrrr;r2r:rN�classmethodrSr	r	r	rr1hsr1c@s$eZdZdZedd��Zdd�ZdS)rz�Base class for components.

    Every component can declare what extension points it provides, as
    well as what extension points of other components it extends.
    cGs@t�d�}|j}||jurd|vsJd��|�dg��|�dS)z�Can 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�	_getframe�f_locals�	f_globalsr?�extend)�
interfaces�frame�locals_r	r	rr�s
�zComponent.implementscCsd|jj|jjfS)z1Return a textual representation of the component.z<Component %s.%s>)rrr
rr	r	rr6�s�zComponent.__repr__N)r
rrr�staticmethodrr6r	r	r	rr�s


r)�	metaclassc@sPeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�ZdS)rHz8The component manager keeps a pool of active components.cCs*i|_i|_t|t�r||j|j<dSdS)z!Initialize the component manager.N)r5�enabledrJrrrr	r	rr�s

�zComponentManager.__init__cCs
||jvS)zKReturn whether the given class is in the list of active
        components.)r5�rr,r	r	r�__contains__�s
zComponentManager.__contains__c
Cs||�|�sdS|j�|�}|s<t|t�s<|tjvr td|j��z||�}W|St	y;}ztd||f��d}~ww|S)z�Activate the component instance for the given class, or
        return the existing instance if the component has already been
        activated.

        Note that `ComponentManager` components can't be activated
        that way.
        NzComponent "%s" not registeredz'Unable to instantiate component %r (%s))
�
is_enabledr5r3rGrHr1r;rr
�	TypeError)rr,r.�er	r	r�__getitem__�s 


����zComponentManager.__getitem__cCs$||jvr
|�|�|j|<|j|S)z4Return whether the given component class is enabled.)r_�is_component_enabledr`r	r	rrb�s

zComponentManager.is_enabledcCs(t|t�s|j}d|j|<d|j|<dS)zdForce a component to be disabled.

        :param component: can be a class or an instance.
        FN)rJr9rr_r5�rr.r	r	r�disable_component�s

z"ComponentManager.disable_componentcCst|t�s|j}d|j|<dS)z{Force a component to be enabled.

        :param component: can be a class or an instance.

        :since: 1.0.13
        TN)rJr9rr_rgr	r	r�enable_components
z!ComponentManager.enable_componentcC�dS)zpCan be overridden by sub-classes so that special
        initialization for components can be provided.
        Nr	rgr	r	rrKsz$ComponentManager.component_activatedcCrj)a[Can be overridden by sub-classes to veto the activation of
        a component.

        If this method returns `False`, the component was disabled
        explicitly.  If it returns `None`, the component was neither
        enabled nor disabled explicitly. In both cases, the component
        with the given class will not be available.
        Tr	r`r	r	rrfs	z%ComponentManager.is_component_enabledN)r
rrrrrarerbrhrirKrfr	r	r	rrH�s
rH)rU�__all__r�	ExceptionrrrPr�objectrr#rr9r1rrrHr	r	r	r�<module>sK