https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/trac/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/trac/__pycache__/resource.cpython-310.pyc
o

�k�`�@�@s�ddlTddlmZmZddlmZddlmZGdd�de�Z	Gdd�de�Z
Gd	d
�d
e�ZGdd�de
�ZGd
d�de�Zdd�Zd$dd�Zdd�Zdd�Zdd�Zd%dd�Zd%dd�Zd$dd �Zd!d"�Zd#S)&�)�*)�Fragment�tag)�classes)�_c@�eZdZdZdS)�ResourceExistsErrorz6Thrown when attempting to insert an existing resource.N��__name__�
__module__�__qualname__�__doc__�rr�//usr/lib/python3/dist-packages/trac/resource.pyr�rc@r)�ResourceNotFoundz0Thrown when a non-existent resource is requestedNr	rrrrrrrc@s.eZdZdd�Zdd�Zddd�Zd	d
�ZdS)�IResourceManagercC�dS)zZReturn resource realms managed by the component.

        :rtype: `str` generator
        Nrrrrr�get_resource_realms#�z$IResourceManager.get_resource_realmscKr)aoReturn the canonical URL for displaying the given resource.

        :param resource: a `Resource`
        :param href: an `Href` used for creating the URL

        Note that if there's no special rule associated to this realm for
        creating URLs (i.e. the standard convention of using realm/id applies),
        then it's OK to not define this method.
        Nr)�resource�href�kwargsrrr�get_resource_url)rz!IResourceManager.get_resource_url�defaultNcKr)a;Return a string representation of the resource, according to the
        `format`.

        :param resource: the `Resource` to describe
        :param format: the kind of description wanted. Typical formats are:
                       `'default'`, `'compact'` or `'summary'`.
        :param context: an optional rendering context to allow rendering rich
                        output (like markup containing links)
        :type context: `ResourceContext`

        Additional keyword arguments can be given as extra information for
        some formats.

        For example, the ticket with the id 123 is represented as:
         - `'#123'` in `'compact'` format,
         - `'Ticket #123'` for the `default` format.
         - `'Ticket #123 (closed defect): This is the summary'` for the
           `'summary'` format

        Note that it is also OK to not define this method if there's no
        special way to represent the resource, in which case the standard
        representations 'realm:id' (in compact mode) or 'Realm id' (in
        default mode) will be used.
        Nr)r�format�contextrrrr�get_resource_description4rz)IResourceManager.get_resource_descriptioncCr)z�Check whether the given `resource` exists physically.

        :rtype: bool

        Attempting to retrieve the model object for a non-existing
        resource should raise a `ResourceNotFound` exception.
        (''since 0.11.8'')
        Nr)rrrr�resource_existsOrz IResourceManager.resource_exists)rN)r
rrrrrrrrrrr!s

rcsVeZdZdZdZdd�Zdd�Zdd�Z	
	
d�fdd�	Zdd
d�Z	ddd�Z
�ZS)�Resourcea�Resource identifier.

    This specifies as precisely as possible *which* resource from a Trac
    environment is manipulated.

    A resource is identified by:
     - a `realm` (a string like `'wiki'` or `'ticket'`)
     - an `id`, which uniquely identifies a resource within its realm.
       If the `id` information is not set, then the resource represents
       the realm as a whole.
     - an optional `version` information.
       If `version` is `None`, this refers by convention to the latest
       version of the resource.

    Some generic and commonly used rendering methods are associated as well
    to the Resource object. Those properties and methods actually delegate
    the real work to the Resource's manager.
    ��realm�id�version�parentcCspg}|}|r/|j}|jr|dt|j�7}|jdur#|dt|j�7}|�|p(d�|j}|sdd�t|��S)N�:�@�z
<Resource %r>z, )r!r"�strr#�appendr$�join�reversed)�self�path�r�namerrr�__repr__ps
�zResource.__repr__cCs0|j|jko|j|jko|j|jko|j|jkS�Nr )r,�otherrrr�__eq__}s
�
�
�zResource.__eq__cCs2d}|}|r||j|j|jf7}|j}|st|�S)z7Hash this resource descriptor, including its hierarchy.r)r!r"r#r$�hash)r,r-�currentrrr�__hash__�s�zResource.__hash__NFcs�|}t|t�r6|dur|dur|dur|S|j}|dur|j}|dur.||jkr,|j}nd}|dur5|j}n|dur<d}|durBd}|durHd}t��|�}||_||_||_||_|S)a�Create a new Resource object from a specification.

        :param resource_or_realm: this can be either:
           - a `Resource`, which is then used as a base for making a copy
           - a `str`, used to specify a `realm`
        :param id: the resource identifier
        :param version: the version or `None` for indicating the latest version

        >>> main = Resource('wiki', 'WikiStart')
        >>> repr(main)
        "<Resource 'wiki:WikiStart'>"

        >>> Resource(main) is main
        True

        >>> main3 = Resource(main, version=3)
        >>> repr(main3)
        "<Resource 'wiki:WikiStart@3'>"

        >>> main0 = main3(version=0)
        >>> repr(main0)
        "<Resource 'wiki:WikiStart@0'>"

        In a copy, if `id` is overridden, then the original `version` value
        will not be reused.

        >>> repr(Resource(main3, id="WikiEnd"))
        "<Resource 'wiki:WikiEnd'>"

        >>> repr(Resource(None))
        "<Resource ''>"
        FN)�
isinstancerr!r"r#r$�super�__new__)�cls�resource_or_realmr"r#r$r!r��	__class__rrr9�s4"

�zResource.__new__cCst|dur|n||||�S)z�Create a new Resource using the current resource as a template.

        Optional keyword arguments can be given to override `id` and
        `version`.
        F�r)r,r!r"r#r$rrr�__call__�szResource.__call__cCst||||�S)z�Retrieve a child resource for a secondary `realm`.

        Same as `__call__`, except that this one sets the parent to `self`.

        >>> repr(Resource(None).child('attachment', 'file.txt'))
        "<Resource ', attachment:file.txt'>"
        r>)r,r!r"r#rrr�child�szResource.child)NFFF)FFFF)FF)r
rrr
�	__slots__r0r3r6r9r?r@�
__classcell__rrr<rrZs
�
?
rc@s0eZdZdZee�Zdd�Zdd�Zdd�Z	dS)	�ResourceSystemz�Resource identification and description manager.

    This component makes the link between `Resource` identifiers and their
    corresponding manager `Component`.
    cCs
d|_dSr1)�_resource_managers_map)r,rrr�__init__��
zResourceSystem.__init__cCsB|jsi}|jD]}|��pgD]}|||<qq||_|j�|�S)z�Return the component responsible for resources in the given `realm`

        :param realm: the realm name
        :return: a `Component` implementing `IResourceManager` or `None`
        )rD�resource_managersr�get)r,r!�map�manager�
manager_realmrrr�get_resource_manager�s

�z#ResourceSystem.get_resource_managercCs0g}|jD]}|��pgD]}|�|�q
q|S)z:Return a list of all the realm names of resource managers.)rGrr))r,�realmsrJr!rrr�get_known_realms�s
�zResourceSystem.get_known_realmsN)
r
rrr
�ExtensionPointrrGrErLrNrrrrrC�srCcKs\t|��|j�}|rt|d�r|j||fi|��Sd|ji}|�|�||j|jfi|��S)a�Retrieve the canonical URL for the given resource.

    This function delegates the work to the resource manager for that
    resource if it implements a `get_resource_url` method, otherwise
    reverts to simple '/realm/identifier' style URLs.

    :param env: the `Environment` where `IResourceManager` components live
    :param resource: the `Resource` object specifying the Trac resource
    :param href: an `Href` object used for building the URL

    Additional keyword arguments are translated as query parameters in
    the URL.

    >>> from trac.test import EnvironmentStub
    >>> from trac.web.href import Href
    >>> env = EnvironmentStub()
    >>> href = Href('/trac.cgi')
    >>> main = Resource('generic', 'Main')
    >>> get_resource_url(env, main, href)
    '/trac.cgi/generic/Main'

    >>> get_resource_url(env, main(version=3), href)
    '/trac.cgi/generic/Main?version=3'

    >>> get_resource_url(env, main(version=3), href)
    '/trac.cgi/generic/Main?version=3'

    >>> get_resource_url(env, main(version=3), href, action='diff')
    '/trac.cgi/generic/Main?action=diff&version=3'

    >>> get_resource_url(env, main(version=3), href, action='diff', version=5)
    '/trac.cgi/generic/Main?action=diff&version=5'

    rr#)rCrLr!�hasattrrr#�updater")�envrrrrJ�argsrrrr
s#

rrcKs^t|��|j�}|rt|d�r|j||fi|��Sd|j|jf}|dkr-td||jd�}|S)a.Retrieve a standardized description for the given resource.

    This function delegates the work to the resource manager for that
    resource if it implements a `get_resource_description` method,
    otherwise reverts to simple presentation of the realm and identifier
    information.

    :param env: the `Environment` where `IResourceManager` components live
    :param resource: the `Resource` object specifying the Trac resource
    :param format: which formats to use for the description

    Additional keyword arguments can be provided and will be propagated
    to resource manager that might make use of them (typically, a `context`
    parameter for creating context dependent output).

    >>> from trac.test import EnvironmentStub
    >>> env = EnvironmentStub()
    >>> main = Resource('generic', 'Main')
    >>> get_resource_description(env, main)
    'generic:Main'

    >>> get_resource_description(env, main(version=3))
    'generic:Main'

    >>> get_resource_description(env, main(version=3), format='summary')
    'generic:Main at version 3'

    rz%s:%s�summaryz%(name)s at version %(version)s)r/r#)rCrLr!rPrr"rr#)rRrrrrJr/rrrr5s�rcCs
t||�Sr1�r�rRrrrr�get_resource_name\rFrWcC�t||d�S)N�compactrUrVrrr�get_resource_shortname`�rZcCrX)NrTrUrVrrr�get_resource_summarydr[r\r'cCs�|dvr|St|ddkr|jnd��d�}|�d�D]}|dkr(|r'|��q|r3|dkr3|�|�q||r>d�|�d�Sdd�S)	z�Build a Resource relative to a reference resource.

    :param path: path leading to another resource within the same realm.
    )Nr'�.r�/r'z..r]N)r")r(r"�split�popr)r*)rr-�base�comprrr�get_relative_resourcehs �
�rccKst|t||�|fi|��S)a/Build an URL relative to a resource given as reference.

    :param path: path leading to another resource within the same realm.

    >>> from trac.test import EnvironmentStub
    >>> env = EnvironmentStub()
    >>> from trac.web.href import Href
    >>> href = Href('/trac.cgi')
    >>> main = Resource('wiki', 'Main', version=3)

    Without parameters, return the canonical URL for the resource, like
    `get_resource_url` does.

    >>> get_relative_url(env, main, href)
    '/trac.cgi/wiki/Main?version=3'

    Paths are relative to the given resource:

    >>> get_relative_url(env, main, href, '.')
    '/trac.cgi/wiki/Main?version=3'

    >>> get_relative_url(env, main, href, './Sub')
    '/trac.cgi/wiki/Main/Sub'

    >>> get_relative_url(env, main, href, './Sub/Infra')
    '/trac.cgi/wiki/Main/Sub/Infra'

    >>> get_relative_url(env, main, href, './Sub/')
    '/trac.cgi/wiki/Main/Sub'

    >>> mainsub = main(id='Main/Sub')
    >>> get_relative_url(env, mainsub, href, '..')
    '/trac.cgi/wiki/Main'

    >>> get_relative_url(env, main, href, '../Other')
    '/trac.cgi/wiki/Other'

    References always stay within the current resource realm:

    >>> get_relative_url(env, mainsub, href, '../..')
    '/trac.cgi/wiki'

    >>> get_relative_url(env, mainsub, href, '../../..')
    '/trac.cgi/wiki'

    >>> get_relative_url(env, mainsub, href, '/toplevel')
    '/trac.cgi/wiki/toplevel'

    Extra keyword arguments are forwarded as query parameters:

    >>> get_relative_url(env, main, href, action='diff')
    '/trac.cgi/wiki/Main?action=diff&version=3'

    )rrc)rRrrr-rrrr�get_relative_urlzs
7��rdcCsZt||||d�}t|t�s+t||�du}tj|t|j|d�t|||j	�|r'dndd�}|S)aUtility for generating a link `Element` to the given resource.

    Some component manager may directly use an extra `context` parameter
    in order to directly generate rich content. Otherwise, the textual output
    is wrapped in a link to the resource.
    )rF)�missing�nofollowN)�class_r�rel)
rr7rrr�arr!rr)rRrrr�linkrerrr�render_resource_link�s

�rkcCs:t|��|j�}|rt|d�r|�|�S|jdurdSdS)a2Checks for resource existence without actually instantiating a model.

        :return: `True` if the resource exists, `False` if it doesn't
                 and `None` in case no conclusion could be made
                 (i.e. when `IResourceManager.resource_exists` is not
                 implemented).

        >>> from trac.test import EnvironmentStub
        >>> env = EnvironmentStub()

        >>> resource_exists(env, Resource('dummy-realm', 'dummy-id')) is None
        True
        >>> resource_exists(env, Resource('dummy-realm'))
        False

    rNF)rCrLr!rPrr")rRrrJrrrr�s

�rN)r)r')�	trac.core�trac.util.htmlrr�trac.util.presentationr�trac.util.translationr�	TracErrorrr�	Interfacer�objectr�	ComponentrCrrrWrZr\rcrdrkrrrrr�<module>s&9	(
+'


;

https://t.me/RX1948 - 2025