File: //usr/lib/python3/dist-packages/trac/__pycache__/resource.cpython-310.pyc
o
�k�`�@ � @ s� d dl T d dlmZmZ d dlmZ d dlmZ G dd� de�Z G dd� de�Z
G d d
� d
e�ZG dd� de
�ZG d
d� de�Zdd� Zd$dd�Zdd� Zdd� Zdd� Zd%dd�Zd%dd�Zd$dd �Zd!d"� Zd#S )&� )�*)�Fragment�tag)�classes)�_c @ � e Zd ZdZdS )�ResourceExistsErrorz6Thrown when attempting to insert an existing resource.N��__name__�
__module__�__qualname__�__doc__� r r �//usr/lib/python3/dist-packages/trac/resource.pyr � r c @ r )�ResourceNotFoundz0Thrown when a non-existent resource is requestedNr r r r r r r r c @ s. e Zd Zdd� Zdd� Zddd�Zd d
� ZdS )�IResourceManagerc C � dS )zZReturn resource realms managed by the component.
:rtype: `str` generator
Nr r r r r �get_resource_realms# � z$IResourceManager.get_resource_realmsc K r )ao Return 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�kwargsr r r �get_resource_url) r z!IResourceManager.get_resource_url�defaultNc K r )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�contextr r r r �get_resource_description4 r z)IResourceManager.get_resource_descriptionc C r )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 )r r r r �resource_existsO r z IResourceManager.resource_exists)r N)r
r r r r r r r r r r r ! s
r c sV e Zd ZdZdZdd� 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�parentc C sp g }| }|r/|j }|jr|dt|j� 7 }|jd ur#|dt|j� 7 }|�|p(d� |j}|sdd�t|�� S )N�:�@� z
<Resource %r>z, )r! r"