File: //usr/lib/python3/dist-packages/tracopt/perm/__pycache__/config_perm_provider.cpython-310.pyc
o
�k�`
� @ s4 d dl T d dlmZ d dlmZ G dd� de�ZdS )� )�*)�
ConfigSection)�IPermissionRequestorc @ s, e Zd ZdZee� eddd�Zdd� ZdS )�ExtraPermissionsProviderz�Define arbitrary permissions.
Documentation can be found on the [wiki:TracIni#extra-permissions-section]
page after enabling the component.zextra-permissionsa| This section provides a way to add arbitrary permissions to a
Trac environment. This can be useful for adding new permissions to use
for workflow actions, for example.
To add new permissions, create a new section `[extra-permissions]` in
your `trac.ini`. Every entry in that section defines a meta-permission
and a comma-separated list of permissions. For example:
{{{#!ini
[extra-permissions]
EXTRA_ADMIN = EXTRA_VIEW, EXTRA_MODIFY, EXTRA_DELETE
}}}
This entry will define three new permissions `EXTRA_VIEW`,
`EXTRA_MODIFY` and `EXTRA_DELETE`, as well as a meta-permissions
`EXTRA_ADMIN` that grants all three permissions.
The permissions are created in upper-case characters regardless of
the casing of the definitions in `trac.ini`. For example, the
definition `extra_view` would create the permission `EXTRA_VIEW`.
If you don't want a meta-permission, start the meta-name with an
underscore (`_`):
{{{#!ini
[extra-permissions]
_perms = EXTRA_VIEW, EXTRA_MODIFY
}}}
)�docc C s� i }| j �� D ]/\}}dd� |�d�D �}|D ]}|�|g � q|�� �� }|r6|�d�s6|�|g ��|� qdd� |�� D �S )Nc S s g | ]}|� � �� �qS � )�strip�upper)�.0�eachr r �C/usr/lib/python3/dist-packages/tracopt/perm/config_perm_provider.py�
<listcomp>: s zCExtraPermissionsProvider.get_permission_actions.<locals>.<listcomp>�,�_c S s g | ]\}}|r||fn|�qS r r )r
�k�vr r r r
@ s ) �extra_permissions_section�options�split�
setdefaultr r �
startswith�extend�items)�self�permissions�meta�perms�permr r r �get_permission_actions7 s �z/ExtraPermissionsProvider.get_permission_actionsN) �__name__�
__module__�__qualname__�__doc__�
implementsr r r r r r r r r s �r N)� trac.core�trac.configr � trac.permr � Componentr r r r r �<module> s