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__/perm.cpython-310.pyc
o

�k�`���@s|ddlZddlZddlmZddlmZmZmZddlm	Z	ddl
mZmZddl
TddlmZmZddlmZmZdd	lmZdd
lmZmZmZmZmZmZddlmZmZgd�Z Gd
d�de!�Z"Gdd�de#�Z$Gdd�de%�Z&Gdd�de%�Z'Gdd�de%�Z(Gdd�de%�Z)Gdd�de*�Z+Gdd�de*�Z,Gdd�de*�Z-Gdd �d e*�Z.Gd!d"�d"e/�Z0Gd#d$�d$e*�Z1dS)%�N)�groupby)�AdminCommandError�IAdminCommandProvider�get_dir_list)�cached)�ExtensionOption�OrderedExtensionsOption)�*)�Resource�get_resource_name)�file_or_std�lazy)�time_now)�path_to_unicode�print_table�printout�stream_encoding�
to_unicode�wrap)�_�N_)�IPermissionRequestor�IPermissionStore�IPermissionPolicy�IPermissionGroupProvider�PermissionError�PermissionSystemcs6eZdZdZed�Zd�fdd�	Zedd��Z�Z	S)	rz2Insufficient permissions to perform the operation.�	ForbiddenNcsr||_||_||_|jr)|jr!|jjr!td|jt|j|j�d�}ntd|jd�}n|dur1td�}t��|�dS)Nzt%(perm)s privileges are required to perform this operation on %(resource)s. You don't have the required permissions.)�perm�resourcezd%(perm)s privileges are required to perform this operation. You don't have the required permissions.)rz2Insufficient privileges to perform this operation.)�actionr�env�idrr�super�__init__)�selfr rr!�msg��	__class__��+/usr/lib/python3/dist-packages/trac/perm.pyr$+s��zPermissionError.__init__cCs
|jdS�Nr)�args�r%r)r)r*�message>s
zPermissionError.message�NNNN)
�__name__�
__module__�__qualname__�__doc__r�titler$�propertyr.�
__classcell__r)r)r'r*r&src@seZdZdZdS)�PermissionExistsErrorz0Thrown when a unique key constraint is violated.N)r0r1r2r3r)r)r)r*r7Csr7c@�eZdZdZdd�ZdS)rz=Extension point interface for components that define actions.cC�dS)akReturn a list of actions defined by this component.

        The items in the list may either be simple strings, or
        `(string, sequence)` tuples. The latter are considered to be "meta
        permissions" that group several simple actions under one name for
        convenience, adding to it if another component already defined that
        name.
        Nr)r)r)r)r*�get_permission_actionsJ�z+IPermissionRequestor.get_permission_actionsN)r0r1r2r3r:r)r)r)r*rG�rc@s8eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
rzeExtension point interface for components that provide storage and
    management of permissions.
    cCr9)z=Return a list of permissions for the specified user.
        Nr)��usernamer)r)r*�get_user_permissionsZr;z%IPermissionStore.get_user_permissionscCr9)zSReturn a list of users that have any of the specified
        permissions.
        Nr))�permissionsr)r)r*�get_users_with_permissions^r;z+IPermissionStore.get_users_with_permissionscCr9)��Return all permissions for all users.

        The permissions are returned as a list of (subject, action)
        formatted tuples.
        Nr)r)r)r)r*�get_all_permissionscr;z$IPermissionStore.get_all_permissionscCr9)z-Grant a user permission to perform an action.Nr)�r>r r)r)r*�grant_permissionjr;z!IPermissionStore.grant_permissioncCr9)z>Revokes the permission of the given user to perform an action.Nr)rDr)r)r*�revoke_permissionmr;z"IPermissionStore.revoke_permissionN)	r0r1r2r3r?rArCrErFr)r)r)r*rUsrc@r8)rz]Extension point interface for components that provide information
    about user groups.
    cCr9)�kReturn a list of names of the groups that the user with the
        specified name is a member of.
        Nr)r=r)r)r*�get_permission_groupsvr;z.IPermissionGroupProvider.get_permission_groupsN)r0r1r2r3rHr)r)r)r*rqsrc@r8)rzCA security policy provider used for fine grained permission checks.cCr9)aCheck that the action can be performed by username on the resource

        :param action: the name of the permission
        :param username: the username string or 'anonymous' if there's no
                         authenticated user
        :param resource: the resource on which the check applies.
                         Will be `None`, if the check is a global one and
                         not made on a resource in particular
        :param perm: the permission cache for that username and resource,
                     which can be used for doing secondary checks on other
                     permissions. Care must be taken to avoid recursion.

        :return: `True` if action is allowed, `False` if action is denied,
                 or `None` if indifferent. If `None` is returned, the next
                 policy in the chain will be consulted.

        Note that when checking a permission on a realm resource (i.e. when
        `.id` is `None`), this usually corresponds to some preliminary check
        done before making a fine-grained check on some resource.
        Therefore the `IPermissionPolicy` should be conservative and return:

         * `True` if the action *can* be allowed for some resources in
           that realm. Later, for specific resource, the policy will be able
           to return `True` (allow), `False` (deny) or `None` (don't decide).
         * `None` if the action *can not* be performed for *some* resources.
           This corresponds to situation where the policy is only interested
           in returning `False` or `None` on specific resources.
         * `False` if the action *can not* be performed for *any* resource
           in that realm (that's a very strong decision as that will usually
           prevent any fine-grained check to even happen).

        Note that performing permission checks on realm resources may seem
        redundant for now as the action name itself contains the realm, but
        this will probably change in the future (e.g. `'VIEW' in ...`).
        Nr))r r>rrr)r)r*�check_permissionr;z"IPermissionPolicy.check_permissionN)r0r1r2r3rIr)r)r)r*r|r<rc@sfeZdZdZeee�ee�Zdd�Z	dd�Z
dd�Zdd	�Zd
d�Z
dd
�Zedd��Zdd�ZdS)�DefaultPermissionStorez�Default implementation of permission storage and group management.

    This component uses the `permission` table in the database to store both
    permissions and groups.
    cCst|�|h�d�S)rG�)�sorted�_get_actions_and_groups)r%r>r)r)r*rH�sz,DefaultPermissionStore.get_permission_groupscCs@|h}|jD]}||ur|�|�|�pg�qt|�|�d�S)aqRetrieve a list of permissions for the given user.

        The permissions are stored in the database as (username, action)
        records. There's simple support for groups by using lowercase
        names for the action column: such a record represents a group and
        not an actual permission, and declares that the user is part of
        that group.
        r)�group_providers�updaterHrLrM)r%r>�subjects�providerr)r)r*r?�s	
�z+DefaultPermissionStore.get_user_permissionscCsRt�}dd�|j��D�}|D]}|�|�}|D]}||vr#|�|�qqt|�S)z�Retrieve a list of users that have any of the specified
        permissions

        Users are returned as a list of usernames.
        cSsh|]}|d�qS)rr))�.0�ur)r)r*�	<setcomp>��zDDefaultPermissionStore.get_users_with_permissions.<locals>.<setcomp>)�setr!�get_known_usersr?�addrL)r%r@�result�users�user�
user_perms�groupr)r)r*rA�s	

��z1DefaultPermissionStore.get_users_with_permissionscCs|jS�rB)�_all_permissionsr-r)r)r*rC�sz*DefaultPermissionStore.get_all_permissionscC�*|j�d||f�|j�d||�|`dS)z=Grants a user the permission to perform the specified action.z&INSERT INTO permission VALUES (%s, %s)zGranted permission for %s to %sN�r!�db_transaction�log�infor_�r%r>r r)r)r*rE�s
�z'DefaultPermissionStore.grant_permissioncCr`)z<Revokes a users' permission to perform the specified action.z6DELETE FROM permission WHERE username=%s AND action=%szRevoked permission for %s to %sNrarer)r)r*rF�s�z(DefaultPermissionStore.revoke_permissioncCst|j�d��S)Nz]
                          SELECT username, action FROM permission
                          )rLr!�db_queryr-r)r)r*r_�sz'DefaultPermissionStore._all_permissionsc	Cs�t�}t�}|j}	t|�}t|�}|D]\}}||vr3|��r%|�|�|��s3|�|�|�|�q|t|�krE|t|�krE	||fSq
)zxGet actions and groups for `subjects`, an iterable of username
        and groups that username is a member of.
        )rVr_�len�isupperrX)	r%rP�actions�groups�perms�	num_users�num_actionsr[r r)r)r*rM�s$


��z.DefaultPermissionStore._get_actions_and_groupsN)r0r1r2r3�
implementsrr�ExtensionPointrNrHr?rArCrErFrr_rMr)r)r)r*rJ�s
	

rJc@s$eZdZdZdZee�dd�ZdS)�DefaultPermissionGroupProviderzqPermission group provider providing the basic builtin permission
    groups 'anonymous' and 'authenticated'.
    TcCs dg}|r|dkr|�d�|S)N�	anonymous�
authenticated)�append)r%r>rjr)r)r*rHs
z4DefaultPermissionGroupProvider.get_permission_groupsN)r0r1r2r3�requiredrnrrHr)r)r)r*rps
rpc@s0eZdZdZee�dZdZdd�Zdd�Z	dS)	�DefaultPermissionPolicyz<Default permission policy using the IPermissionStore system.��<cC�i|_t�|_dS�N��permission_cacher�	last_reapr-r)r)r*r$+�z DefaultPermissionPolicy.__init__cCsnt�}||j|jkri|_t�|_|j�|d�\}}|||jkr1t|j��|�}||f|j|<||vp6dS)N�rN)	rr|�CACHE_REAP_TIMEr{�get�CACHE_EXPIRYrr!r?)r%r r>rr�now�	timestampr@r)r)r*rI1s��z(DefaultPermissionPolicy.check_permissionN)
r0r1r2r3rnrr�rr$rIr)r)r)r*ru!sruc@s�eZdZdZdZee�ee�Zee	�Z
eddedd�Z
eddedd	d
�ZdZdZd
d�Zdd�Zdd�Zd,dd�Zedd��Zd,dd�Zdd�Zdd�Z			d-dd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Z 		d.d(d)�Z!d*d+�Z"dS)/rz!Permission management sub-system.T�trac�permission_storerJzuName of the component implementing `IPermissionStore`, which is
        used for managing user and group permissions.�permission_policieszWDefaultWikiPolicy, DefaultTicketPolicy, DefaultPermissionPolicy, LegacyAttachmentPolicyFz�List of components implementing `IPermissionPolicy`, in the order
        in which they will be applied. These components manage fine-grained
        access control to Trac resources.rvrwcCrxryrzr-r)r)r*r$br}zPermissionSystem.__init__c	Cs�|��r||��vrttd|d���|��s&|��|��vr&ttd|d���z
|j�||�WdS|jjj	yR||��vrIt
td||d���t
td||d���w)	a<Grant the user with the given name permission to perform to
        specified action.

        :raises PermissionExistsError: if user already has the permission
                                       or is a member of the group.

        :since 1.3.1: raises PermissionExistsError rather than IntegrityError
        �%(name)s is not a valid action.��namezWPermission %(name)s differs from a defined action by casing only, which is not allowed.z4The user %(user)s already has permission %(action)s.)r[r z4The user %(user)s is already in the group %(group)s.)r[r]N)rh�get_actions�	TracErrorr�upper�storerEr!�db_exc�IntegrityErrorr7rer)r)r*rEhs*	������z!PermissionSystem.grant_permissioncCs|j�||�dS)zJRevokes the permission of the specified user to perform an
        action.N)r�rFrer)r)r*rF�sz"PermissionSystem.revoke_permissionNcCsbi}|jD])}||urq|��pgD]}t|t�r'|�|dg��|d�q|�|g�qq|S)aUGet all actions from permission requestors as a `dict`.

        The keys are the action names. The values are the additional actions
        granted by each action. For simple actions, this is an empty list.
        For meta actions, this is the list of actions covered by the action.

        :since 1.0.17: added `skip` argument.
        rrK)�
requestorsr:�
isinstance�tuple�
setdefault�extend�r%�skipri�	requestorr r)r)r*�get_actions_dict�s	

�z!PermissionSystem.get_actions_dictcCs|��Sry�r�r-r)r)r*ri�szPermissionSystem.actionscCsZt�}|jD]"}||ur
q|��pgD]}t|t�r"|�|d�q|�|�qqt|�S)z;Get a list of all actions defined by permission requestors.r)rVr�r:r�r�rXrLr�r)r)r*r��s

�zPermissionSystem.get_actionscC�8tdd�|��D�dd�d�}dd�t|dd�d�D�S)	z�Get all groups as a `dict`.

        The keys are the group names. The values are the group members.

        :since: 1.1.3
        css �|]}|d��s|VqdS�rKN�rh�rR�pr)r)r*�	<genexpr>���
�z3PermissionSystem.get_groups_dict.<locals>.<genexpr>cS�|dS�NrKr)�r�r)r)r*�<lambda>��z2PermissionSystem.get_groups_dict.<locals>.<lambda>��keycS�(i|]\}}|tdd�t|�D���qS)cs��|]}|dVqdSr~r)�rR�ir)r)r*r����z>PermissionSystem.get_groups_dict.<locals>.<dictcomp>.<genexpr>�rL�list�rR�k�gr)r)r*�
<dictcomp>���z4PermissionSystem.get_groups_dict.<locals>.<dictcomp>cSr�r�r)r�r)r)r*r��r��rLrCr)r%rjr)r)r*�get_groups_dict�s��z PermissionSystem.get_groups_dictcCr�)	z�Get all users as a `dict`.

        The keys are the user names. The values are the actions possessed
        by the user.

        :since: 1.1.3
        css �|]}|d��r|VqdSr�r�r�r)r)r*r��r�z2PermissionSystem.get_users_dict.<locals>.<genexpr>cSr�r+r)r�r)r)r*r��r�z1PermissionSystem.get_users_dict.<locals>.<lambda>r�cSr�)csr�r�r)r�r)r)r*r��r�z=PermissionSystem.get_users_dict.<locals>.<dictcomp>.<genexpr>r�r�r)r)r*r��r�z3PermissionSystem.get_users_dict.<locals>.<dictcomp>cSr�r+r)r�r)r)r*r��r�r�)r%rkr)r)r*�get_users_dict�s��zPermissionSystem.get_users_dictcs^|s
t�|��d�S|���|j�|�pg}|r%��fdd�|�|�D�S��fdd�|D�S)a�Return the permissions of the specified user.

        The return value is a dictionary containing all the actions
        granted to the user mapped to `True`.

        :param undefined: if `True`, include actions that are not defined
            in any of the `IPermissionRequestor` implementations.
        :param expand_meta: if `True`, expand meta permissions.

        :since 1.3.1: added the `undefined` parameter.
        :since 1.3.3: added the `expand_meta` parameter.
        Tc�i|]}�s
|�vr|d�qS�Tr)r��ri�	undefinedr)r*r�����z9PermissionSystem.get_user_permissions.<locals>.<dictcomp>cr�r�r)r�r�r)r*r��r�)�dict�fromkeysr�r�r�r?�expand_actions)r%r>r��expand_meta�user_permissionsr)r�r*r?�sz%PermissionSystem.get_user_permissionscCs.t�}|jD]}|�|�|�pg�qt|�S)aReturn a sorted list of groups that `username` belongs to.

        Groups are recursively expanded such that if `username` is a
        member of `group1` and `group1` is a member of `group2`, both
        `group1` and `group2` will be returned.

        :since: 1.3.3
        )rVrNrOrHrL)r%r>�user_groupsrQr)r)r*rH�s	
z&PermissionSystem.get_permission_groupscCs|j��pgSr^)r�rCr-r)r)r*rC�sz$PermissionSystem.get_all_permissionsc	s�t�}||j|jkri|_||_|j�|d�\}}|||jkr#|Si�|����D]\}}|D]}��|t	���
|�q1q+t	�����fdd���|�|j���pUg}||f|j|<|S)zrReturn all users that have the specified permission.

        Users are returned as a list of user names.
        r~cs4|�vr��|���|d�D]}�|�qdSdS�Nr)�rXr�)r ��append_with_parents�
parent_map�satisfying_permsr)r*r��

�zGPermissionSystem.get_users_with_permission.<locals>.append_with_parents)
rr|rr{r�r�r��itemsr�rVrXr�rA)	r%�
permissionr�r�r@�parent�children�childrkr)r�r*�get_users_with_permission�s(��z*PermissionSystem.get_users_with_permissioncs8|���t�����fdd��|D]}�|�qt��S)z-Helper method for expanding all meta actions.cs4|�vr��|���|d�D]}�|�qdSdSr�r�)r �a��all_actions�
expand_action�expanded_actionsr)r*r�r�z6PermissionSystem.expand_actions.<locals>.expand_action)r�rVrL)r%rir�r)r�r*r�s
zPermissionSystem.expand_actionsc	Cs�|durd}|r|jdurd}|jD]#}|�||||�}|dur5|j�d|jj|r+dnd|||�|Sq|j�d|||�dS)z_Return True if permission to perform action for the given
        resource is allowed.
        Nrqz%s %s %s performing %s on %r�allows�deniesz(No policy allowed %s performing %s on %rF)�realm�policiesrIrc�debugr(r0)r%r r>rr�policy�decisionr)r)r*rI(s(

�
���z!PermissionSystem.check_permissioncCs|j|d�}d|fgS)z;Implement the global `TRAC_ADMIN` meta permission.
        )r��
TRAC_ADMINr�)r%rir)r)r*r:@s
z'PermissionSystem.get_permission_actionsry)NFT)NNN)#r0r1r2r3rtrnrror�rrNrrr�rrr�r�rr$rErFr�r
rir�r�r�r?rHrCr�r�rIr:r)r)r)r*rEsL��






�

�rc@s`eZdZdZdZ		ddd�Zdd�Zdd	d
�Z		ddd�Zd
d�Z	eZ
		ddd�ZeZdS)�PermissionCacheaaCache that maintains the permissions of a single user.

    Permissions are usually checked using the following syntax:

        'WIKI_MODIFY' in perm

    One can also apply more fine grained permission checks and
    specify a specific resource for which the permission should be available:

        'WIKI_MODIFY' in perm('wiki', 'WikiStart')

    If there's already a `page` object available, the check is simply:

        'WIKI_MODIFY' in perm(page.resource)

    If instead of a check, one wants to assert that a given permission is
    available, the following form should be used:

        perm.require('WIKI_MODIFY')

        or

        perm('wiki', 'WikiStart').require('WIKI_MODIFY')

        or

        perm(page.resource).require('WIKI_MODIFY')

    When using `require`,  a `PermissionError` exception is raised if the
    permission is missing.
    �r!r>�	_resource�_cacheNcCs,||_|pd|_||_|duri}||_dS)Nrqr�)r%r!r>r�cacherjr)r)r*r$js

zPermissionCache.__init__cCs|rt|||�S|jSry)r
r�)r%�realm_or_resourcer"�versionr)r)r*�_normalize_resourcessz#PermissionCache._normalize_resourceFcCs@|rt|||�nd}|r|jr||jkr|St|j|j||j�S)z�Convenience function for using thus:
            'WIKI_VIEW' in perm(context)
        or
            'WIKI_VIEW' in perm(realm, id, version)
        or
            'WIKI_VIEW' in perm(resource)

        N)r
r�r�r!r>r�)r%r�r"r�rr)r)r*�__call__ys
���zPermissionCache.__call__cCs|�|||�}|�||�Sry)r��_has_permission)r%r r�r"r�rr)r)r*�has_permission�szPermissionCache.has_permissionc	Cs�|jt|�|f}|j�|�}|r|\}}||kr|Sd|f|j|<|}||jur2t|j|j||j�}t|j��||j||�}||f|j|<|S)NF)	r>�hashr�r�r�r�r!rrI)	r%r rr�r�cache_decision�cache_resourcerr�r)r)r*r��s"
��zPermissionCache._has_permissioncCs>|�|||�}|�||�s|durt|||j��t|d��dS)N)r&)r�r�rr!)r%r r�r"r�r.rr)r)r*�require�s
�zPermissionCache.requirer/)FF)NFF)NFFN)
r0r1r2r3�	__slots__r$r�r�r�r��__contains__r��assert_permissionr)r)r)r*r�Gs" 
�	

�
�r�c@s~eZdZdZee�dd�Zdd�Zdd�Zdd	�Z	d
d�Z
dd
�Zdd�Zddd�Z
dd�Zdd�Zddd�Zddd�ZdS)�PermissionAdminzAtrac-admin command provider for permission system administration.ccsj�ddd|j|jfVddd|j|jfVddd|j|jfVd	d
d|j|jfVdd
d
|j|jfVdS)Nzpermission listz[user]zList permission ruleszpermission addz<user> <action> [action] [...]zAdd a new permission rulezpermission removezRemove a permission rulezpermission exportz[file]z2Export permission rules to a file or stdout as CSVzpermission importz3Import permission rules from a file or stdin as CSV)	�_complete_list�_do_list�
_complete_add�_do_add�_complete_remove�
_do_remove�_complete_import_export�
_do_export�
_do_importr-r)r)r*�get_admin_commands�s*�����
�z"PermissionAdmin.get_admin_commandscCsdd�t|j���D�S)NcSsh|]\}}|�qSr)r))rRr[r r)r)r*rT�rUz0PermissionAdmin.get_user_list.<locals>.<setcomp>�rr!rCr-r)r)r*�
get_user_list�s�zPermissionAdmin.get_user_listcs�fdd�t|j���D�S)Ncsg|]
\}}|�kr|�qSr)r))rR�subjectr �r[r)r*�
<listcomp>�s�z2PermissionAdmin.get_user_perms.<locals>.<listcomp>r�)r%r[r)r�r*�get_user_perms�s
�zPermissionAdmin.get_user_permscCst|�dkr
|��SdSr�)rgr��r%r,r)r)r*r��s�zPermissionAdmin._complete_listcCsXt|�dkr
|��St|�dkr*tt|j����t|�|d��t|dd��SdS�NrK�r���)rgr�rVrr!r�r�r�r)r)r*r��s���zPermissionAdmin._complete_addcCsFt|�dkr
|��St|�dkr!t|�|d��t|dd��SdSr)rgr�rVr�r�r)r)r*r��s
"�z PermissionAdmin._complete_removecCst|�dkrt|d�SdS)NrKr)rgrr�r)r)r*r��s�z'PermissionAdmin._complete_import_exportNcCs�t|j�}|r!g}|j|dd�}|D]
}||r|�||f�qn|��}|��t|td�td�g�t�t	td��|�
�}|��d�|�}t	t|dddd	��t�dS)
NT)r��User�ActionzAvailable actions:z, � �
)�initial_indent�subsequent_indent�linesep)
rr!r?rsrC�sortrr�printrr��joinr)r%r[�permsys�rowsrkr ri�textr)r)r*r��s*
��

�
zPermissionAdmin._do_listcsdt�j�����rttd������fdd�}t|�}|r0||�}|dur'dS|�|�|sdSdS)Nz8All upper-cased tokens are reserved for permission namesc
s�d}z$�jj�|D]}���|�q
Wd�WdS1swYWdSty>}zt|�|WYd}~Sd}~wtyN}zt|�|�d}~wwry)r!rbrEr7rr�r)rir �e�r
r%r[r)r*�grant_actions_atomically�s
�&��
��z9PermissionAdmin._do_add.<locals>.grant_actions_atomically)rr!rhrrr��remove)r%r[rir�actions_to_grant�action_that_failedr)rr*r��s

�zPermissionAdmin._do_addc
Gs�t|j�}|��}|D]T}d}|D]\}}||dfvr)||dfvr)|�||�d}q|s_||��vrD||�|�vrDtd||d�}	t|	��||��vrUtd||d�}	t|	��td|d�}	t|	��qdS)	NFr	TztCannot remove permission %(action)s for user %(user)s. The permission is granted through a meta-permission or group.)r r[zdCannot remove permission %(action)s for user %(user)s. The user has not been granted the permission.r�r�)	rr!rCrFr�r?rr�r)
r%r[rir
rr �foundrSr�r&r)r)r*r�s4
��
�����zPermissionAdmin._do_removec	
Cs�zKt|d��;}|rtjnd}tj||d�}|��}t|�D]}t|�|��}|�dd�|g|D��q|�	�Wd�WdS1sDwYWdSt
ye}zttdt
|pZd�|jd���d}~ww)	N�wr��lineterminatorcSsg|]}|�qSr)r))rR�sr)r)r*r�6sz.PermissionAdmin._do_export.<locals>.<listcomp>z(Cannot export to %(filename)s: %(error)s�stdout��filename�error)r�osr	�csv�writerr�rLr��writerow�flush�IOErrorrrr�strerror)	r%r�fr	r!rZr[rirr)r)r*r�.s&
&�
����zPermissionAdmin._do_exportc
CsJt|j�}|r
tjnd}zct|d��S}tj||d�}|D]?}t|�dkr-tt	d|j
d���|d}|dd�}|��rEtt	d	||j
d
���|�|�}	t
|�t
|	�D]}
|�||
�qRqWd�WdS1shwYWdStjy�}ztt	dt|pd�|j
|d
���d}~wty�}ztt	dt|p�d�|jd���d}~ww)Nr�rrrz@Invalid row %(line)d. Expected <user>, <action>, [action], [...])�linerrKzaInvalid user %(user)s on line %(line)d: All upper-cased tokens are reserved for permission names.)r[r(z9Cannot import from %(filename)s line %(line)d: %(error)s �stdin)rr(rz*Cannot import from %(filename)s: %(error)sr)rr!rr	rr �readerrgrr�line_numrhr�rVrE�Errorrr$r%)r%rr
r	r&r*�rowr[ri�old_actionsr rr)r)r*r�>sV
����
��&�
���
����zPermissionAdmin._do_importry)r0r1r2r3rnrr�r�r�r�r�r�r�r�r�r�r�r�r)r)r)r*r��s

r�)2r r�	itertoolsr�
trac.adminrrr�
trac.cacher�trac.configrr�	trac.core�
trac.resourcer
r�	trac.utilrr
�trac.util.datefmtr�trac.util.textrrrrrr�trac.util.translationrr�__all__�
TracBaseErrorrr�r7�	Interfacerrrr�	ComponentrJrprur�objectr�r�r)r)r)r*�<module>s6 )l$g

https://t.me/RX1948 - 2025