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/ticket/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

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

�k�`�w�@s`ddlZddlmZmZddlmZddlmZddlm	Z	ddl
mZddlm
Z
mZmZddlTdd	lmZmZdd
lmZddlmZmZddlmZmZdd
lmZmZm Z m!Z!ddl"m#Z#ddl$m%Z%ddl&m'Z'm(Z(m)Z)ddl*m+Z+ddl,m-Z-m.Z.m/Z/ddl0m1Z1m2Z2ddl3m4Z4m5Z5dd�Z6dd�Z7dd�Z8Gdd�de�Z9Gdd�de4�Z:dS)�N)�ParsingError�RawConfigParser)�defaultdict)�partial)�resource_filename)�IEnvironmentSetupParticipant)�
ConfigSection�
Configuration�ConfigurationError)�*)�PermissionCache�PermissionSystem)�ResourceNotFound)�ITicketActionController�TicketSystem)�	Component�
Resolution)�exception_to_unicode�get_reporter_id�sub_val�to_list)�tag)�	separated)�_�tag_�	cleandoc_)�RepositoryManager)�Chrome�
add_script�add_script_data)�
MacroError�ProcessorError)�
WikiMacroBase�
parse_argsc	Cs�gddddggd�}ggd�}|��}|�|�tt�}|D]o\}}|�d�}|d}t|�dkrXzdd�|�d	�D�\}	}
Wn	tyHYqwt|	�||d
<|
||d<q|d}||vsgt||t	�rn||||<qt||t
�r~t
|�|||<qt||t�r�t|�|||<q|��D]9\}}
d|
vr�d
|
vr�|
d
|
d<n
|�
dd���|
d<|��D]
\}}|
�||�q�dD]
}t|
d
|d�q�q�|S)z.Given a list of options from [ticket-workflow]�r)�	oldstates�newstate�name�label�default�
operations�permissions)�	set_owner�set_resolution�.�cSsg|]}|���qS�)�strip��.0�xr0r0�>/usr/lib/python3/dist-packages/trac/ticket/default_workflow.py�
<listcomp>F�z)parse_workflow_config.<locals>.<listcomp>z->r%r&r(r'r� )z<none>z< none >N)�copy�updater�dict�split�len�
ValueErrorr�
isinstance�str�int�list�items�replacer1�
setdefaultr)�
rawactions�required_attrs�optional_attrs�known_attrs�actions�option�value�partsr'r%r&�	attribute�action�
attributes�key�valr0r0r5�parse_workflow_config,s\�
�

����rScCst|�d��}t|�}|S)zYUsually passed self.config, this will return the parsed ticket-workflow
    section.
    �ticket-workflow)rB�optionsrS)�config�raw_actionsrJr0r0r5�get_workflow_configcsrXcCs<tdd|�}t|�}|�d�D]\}}|�d||�qdS)z�Loads the ticket-workflow section from the given file (expected to be in
    the 'workflows' tree) into the provided config.
    ztrac.ticketzworkflows/%srTN)rr	rU�set)rV�filename�
new_configr'rLr0r0r5�load_workflow_config_snippetls
�r\c@s�eZdZdZeee�edd�ZdZ	dd�Z
dd�Zd	d
�Zdd�Z
d
d�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%S)&�ConfigurableTicketWorkflowz�Ticket action controller which provides actions according to a
    workflow defined in trac.ini.

    The workflow is defined in the `[ticket-workflow]` section of the
    [wiki:TracIni#ticket-workflow-section trac.ini] configuration file.
    rTa The workflow for tickets is controlled by plugins. By default,
        there's only a `ConfigurableTicketWorkflow` component in charge.
        That component allows the workflow to be configured via this section
        in the `trac.ini` file. See TracWorkflow for more details.
        )�	del_ownerr,�set_owner_to_self�
may_set_ownerr-�del_resolution�leave_status�reset_workflowcCs|��|_|j�d|j�dS)Nz'Workflow actions at initialization: %s
)�get_all_actionsrJ�log�debug��selfr0r0r5�__init__�s
�z#ConfigurableTicketWorkflow.__init__cCs6d|j��vrt|jd�|j��|��|_dSdS)z�When an environment is created, we provide the basic-workflow,
        unless a ticket-workflow section already exists.
        rTzbasic-workflow.iniN)rV�sectionsr\�saverdrJrgr0r0r5�environment_created�s

�z.ConfigurableTicketWorkflow.environment_createdcC�dS�Nr0rgr0r0r5�environment_needs_upgrade��z4ConfigurableTicketWorkflow.environment_needs_upgradecCrmrnr0rgr0r0r5�upgrade_environment�rpz.ConfigurableTicketWorkflow.upgrade_environmentcCs(|j�d|d�}|du}|j�d|d�}t|d�}|j}g}|j��D]G\}	}
|
d}|
d}d|vr:|dkr:q%t|�d	krMd
|vrM||krM||krMq%|
d}
|rX|
dgks\||
vrl|�||
|�rl|�|
d|	f�q%|r�d
|jvr�|t	|j
���vr�|jd
}|�|||�r�|�|dd
f�|S)zbReturns a list of (weight, action) tuples that are valid for this
        request and this ticket.�statusN�owner�authorr*r&rbrr/r_r%r)�_reset)�_old�getr�resourcerJrCr=�_is_action_allowed�appendr�env�get_all_status)rh�req�ticket�
ticket_status�exists�ticket_ownerrtrx�allowed_actions�action_name�action_infor*r&r%�resetr0r0r5�get_ticket_actions�s8	

��
z-ConfigurableTicketWorkflow.get_ticket_actionscCs6|�|�}|d}|r|D]	}||vrdSq
dSdS)zMReturns `True` if the workflow action is allowed for the `resource`.
        r+FT)�perm)rhr}rOrx�
perm_cache�required_perms�
permissionr0r0r5ry�s
�z-ConfigurableTicketWorkflow._is_action_allowedcCsTt�}|j��D]}|�|d�|�|d�q|�d�|�d�|�d�|S)zEReturn a list of all states described by the configuration.

        r%r&rr$N)rYrJ�valuesr:�add�discard)rh�
all_statusrPr0r0r5r|�s


z)ConfigurableTicketWorkflow.get_all_statusc
s4|j�d|�|j|}|d}|d}|j�d|d�}|j�d|d�}|d}	t|d�}
tt|j�j	||j
d�}tt|j�j||j
d��||�}|du}
t|j�}g}g}d	|vrj|�
td
��|�
td��d|vru|�
td
��d|vs~d|v�rl|�|||�}d|vr�|
}n!d|vr�|
s�|j}n|p�d}|dur�||vr�|�d|�nt|��d|}|s�|j�||�}|�
tdtjd|||d�d��|
r�|dur�|�
td��n�|�
td|d��n�t|�dk�r,tjd|||dd�}||d�}|�
tdt||�d��|
�r|du�r|�
td|d��n�|d|dk�r+|�
td||d��ny|j�||��|�
tdtj�fdd �t�fd!d"�|D��D�||d#�d��|
�rZ|du�rb|�
td$��nC|�
td%|d��n9d&|v�r�||
�}|
�r}|du�r�|�
td|d��n||
k�r�|�
td||d��n||	k�r�|�
td'|d��d(|v�r2d)d �t�|j�D�}d(|v�r�t|��|d(}t�fd*d"�|D���r�ttd+���|�s�ttd,���d-|}t|�dk�r
tjd|||dd�}|�
td.t|d|�d/��|�
td0|dd1��n%|j�||j��|�
td.tj�fd2d �|D�||d#�d/��|�
td3��d4|v�r>|�
td5��d6|v�rdt|�dk�rc|�
td7|d8��|�
|�r^td'|d�ntd9��n|ddu�ru|�
td:|	d1��n|	|k�r�|�
td;|	d1��|tt|d<��t|�r�t|d=d>��fSd?�fS)@Nz)render_ticket_action_control: action "%s"r(r*rsrrr&rt�rxrczfrom invalid statezCurrent state no longer existsr^zThe ticket will be disownedr,r`r�action_%s_reassign_ownerzto %(owner)s�text)�type�idr'rL)rsz$The owner will be the specified userzFThe owner will be changed from %(current_owner)s to the specified user)�
current_ownerr/�hiddenzThe owner will be %(new_owner)s)�	new_ownerzAThe owner will be changed from %(current_owner)s to %(new_owner)s)r�r�cs4g|]\}}tj||dur|nd|�kpdd��qS)Nr$�rL�selected�rrK)r3r�rL)�selected_ownerr0r5r61s
�

�zKConfigurableTicketWorkflow.render_ticket_action_control.<locals>.<listcomp>c3s�|]	}�|�|fVqdSrnr0)r3rs)�
format_authorr0r5�	<genexpr>3s��zJConfigurableTicketWorkflow.render_ticket_action_control.<locals>.<genexpr>)r�r'z#The owner will be the selected userzEThe owner will be changed from %(current_owner)s to the selected userr_z'The owner will remain %(current_owner)sr-cSsg|]}|j�qSr0�r')r3�rr0r0r5r6Jsc3s�|]}|�vVqdSrnr0r2)�valid_resolutionsr0r5r�N��z�Your workflow attempts to set a resolution but uses undefined resolutions (configuration issue, please contact your Trac admin).zuYour workflow attempts to set a resolution but none is defined (configuration issue, please contact your Trac admin).�action_%s_resolve_resolutionzas %(resolution)s)�
resolutionz&The resolution will be set to %(name)sr�cs$g|]}tj|||�kp
dd��qS)Nr�r�r2)�selected_optionr0r5r6fs
�

�zThe resolution will be setrazThe resolution will be deletedrbz
as %(status)s)rrz$The ticket will remain with no ownerzThe status will be '%(name)s'zNext status will be '%(name)s'r8z. r.r$) rerfrJrvrwrrrr{�
authorinforxr�rrzr�get_allowed_owners�
default_owner�insert�AssertionError�argsrr�inputr=�select�sortedrrY�anyr
�default_resolutionr)rhr}r~rO�this_actionr(r*r�r�next_statusrt�author_info�formatted_current_ownerr��
ticket_system�control�hints�ownersr�r�rs�formatted_new_owner�formatted_author�resolutionsr�r0)r�r�r�r�r5�render_ticket_action_control�sD

��
�
���
�
��
���
���
�

�

�
�

��
���
��
���

����
�
���z7ConfigurableTicketWorkflow.render_ticket_action_controlcCs�|j|}|�|||j�siSi}|d}|dkr||d<|dD]g}|dkr,d|d<q!|dvrW|�d	�}|j�d
||rA|dnd�}	t|	�tkrN|	d}	|�|	|�|d<q!|dkrct|d
�|d<q!|dkrld|d<q!|dkr�|�d�}
|j�d||
r�|
dnd�}||d<q!|j	s�d|vr�|�|d|�|d<|S|ddkr�d|j
vr�d|jvr�d|vr�zt|j
|jd�}Wn
ty�Y|Sw|jp�d}
|dp�d}|
|kr�t|j
|d�}|jr�|j|d<|S)Nr&rrrr*r^r$rs)r,r`r,r�rr_rtrar�r-r��new�	component)rJryrxrwr�r�rB�_sub_owner_keywordrr�r�rv�TicketComponentr{rrs)rhr}r~rOr��updatedrr�	operationr,�newownerr-�
newresolution�old_comp�	old_ownerr��new_compr0r0r5�get_ticket_changes}sj


�

�
����

	�

z-ConfigurableTicketWorkflow.get_ticket_changescCrmrnr0)rhr}r~rOr0r0r5�apply_action_side_effects�rpz4ConfigurableTicketWorkflow.apply_action_side_effectscCs�t|j���}tdd�|��D��}|r0dddgdgdgd�}|��D]\}}|d	�||�q#|��D]\}}|d
sC|j�d|�q4|S)Ncss&�|]}d|dg|dvVqdS)r�r&r%Nr0)r3�ar0r0r5r��s��z=ConfigurableTicketWorkflow.get_all_actions.<locals>.<genexpr>r�Resetr�rc�TICKET_ADMIN)r)r(r&r%r*r+rur&z:Ticket workflow action '%s' doesn't define any transitions)	rS�ticket_workflow_sectionrUr�r�rCrEre�warning)rhrJ�
has_new_stater�rQrRr'�infor0r0r5rd�s*����z*ConfigurableTicketWorkflow.get_all_actionscs�fdd�|j��D�}|S)zsReturn a list of all actions with a given operation
        (for use in the controller's get_all_status())
        cs(g|]\}}�|dvr|d|f�qS)r*r)r0�r3rOr��r�r0r5r6�s
�zGConfigurableTicketWorkflow.get_actions_by_operation.<locals>.<listcomp>)rJrC)rhr�rJr0r�r5�get_actions_by_operation�s
�z3ConfigurableTicketWorkflow.get_actions_by_operationcs6�j�d�d�������fdd��j��D�}|S)z�Return list of all actions with a given operation that are valid
        in the given state for the controller's get_ticket_actions().

        If state='*' (the default), all actions with the given operation are
        returned.
        rrcsPg|]$\}}�|dvr&d|dvs�|dvr���|�j�r|d|f�qS)r*rr%r))ryrxr��r�r}rhrrr~r0r5r6�s�
�zOConfigurableTicketWorkflow.get_actions_by_operation_for_req.<locals>.<listcomp>)rvrwrJrC)rhr}r~r�rJr0r�r5� get_actions_by_operation_for_req�s
�z;ConfigurableTicketWorkflow.get_actions_by_operation_for_reqcs`d|vr|�|d|�St|j�jr.t|j��d�}tt|j|jd��t	�fdd�|D��SdS)aPReturns users listed in the `set_owner` field of the action or
        possessing the `TICKET_MODIFY` permission if `set_owner` is not
        specified.

        This method can be overridden in a subclasses in order to
        customize the list of users that populate the assign-to select
        box.

        :since: 1.3.2
        r,�
TICKET_MODIFYr�c3s"�|]}d�|d�vr|VqdS)r�)�usernameNr0�r3�u��cacher0r5r�s���z@ConfigurableTicketWorkflow.get_allowed_owners.<locals>.<genexpr>N)
�	_to_usersrr{�restrict_ownerr
�get_users_with_permissionrrrxr�)rhr}r~rO�usersr0r�r5r��s��z-ConfigurableTicketWorkflow.get_allowed_ownerscCsL|dvr$d}|dr"z
t|j|d�}Wn
tyY|Sw|j}|S|S)zbSubstitute keywords from the default_owner field.

        < default > -> component owner
        )z< default >z	<default>r$r�)r�r{rrs)rhrsr~r�r�r0r0r5r�s�z-ConfigurableTicketWorkflow._sub_owner_keywordcs>t�j������������fdd��t���|�t��S)z�Finds all users contained in the list of `users_perms_and_groups`
        by recursive lookup of users when a `group` is encountered.
        cs�|D]B}|dkr��dd��j��D��q|��r4|}��|�D]}|t�j|�j�vr2��|�q!q|�vr>��|�q��|�qdS)N�
authenticatedcS�h|]}|d�qS)rr0r�r0r0r5�	<setcomp>0r7zNConfigurableTicketWorkflow._to_users.<locals>.append_owners.<locals>.<setcomp>)r:r{�get_known_users�isupperr�rrxr�)�users_perms_and_groups�user_perm_or_groupr��user��
append_owners�groupsr��psrhr~r0r5r�-s 
�
���z;ConfigurableTicketWorkflow._to_users.<locals>.append_owners)r
r{�get_groups_dictrYr�)rhr�r~r0r�r5r�&s
z$ConfigurableTicketWorkflow._to_usersN)�__name__�
__module__�__qualname__�__doc__�
implementsrrrr�r*rirlrorqr�ryr|r�r�r�rdr�r�r�r�r�r0r0r0r5r]vs0
�	)

F	r]c@s"eZdZdZed�Zddd�ZdS)�
WorkflowMacro�messagesa�Render a workflow graph.

    This macro accepts a TracWorkflow configuration and renders the states
    and transitions as a directed graph. If no parameters are given, the
    current ticket workflow is rendered.

    In [WikiProcessors WikiProcessor] mode the `width` and `height`
    arguments can be specified (Defaults: `width = 800` and `height = 600`).

    The repository-scoped path of a workflow file can be specified as either
    a macro or !WikiProcessor `file` argument. The file revision can be
    specified by appending `@<rev>` to the path. The `file` argument value
    must be enclosed in single or double quotes. //(Since 1.3.2)//.

    Examples:
    {{{
    [[Workflow()]]

    [[Workflow(go = here -> there; return = there -> here)]]

    [[Workflow(file=/contrib/workflow/enterprise-workflow.ini@1)]]

    {{{#!Workflow file="/contrib/workflow/enterprise-workflow.ini"
    }}}

    {{{#!Workflow width=700 height=700
    leave = * -> *
    leave.operations = leave_status
    leave.default = 1

    create = <none> -> new
    create.default = 1

    create_and_assign = <none> -> assigned
    create_and_assign.label = assign
    create_and_assign.permissions = TICKET_MODIFY
    create_and_assign.operations = may_set_owner

    accept = new,assigned,accepted,reopened -> accepted
    accept.permissions = TICKET_MODIFY
    accept.operations = set_owner_to_self

    resolve = new,assigned,accepted,reopened -> closed
    resolve.permissions = TICKET_MODIFY
    resolve.operations = set_resolution

    reassign = new,assigned,accepted,reopened -> assigned
    reassign.permissions = TICKET_MODIFY
    reassign.operations = set_owner

    reopen = closed -> reopened
    reopen.permissions = TICKET_CREATE
    reopen.operations = del_resolution
    }}}
    }}}
    Nc
Csl|dur|��}|s|s|j�d�}n�|du}|r%t|�d}|�d�}n
|�d�}|s2|s2td��|rPt|�t|j��	|�}	|	durOtt
dt�|�d���n|r`d�
dd	�|�d
�D��}	n|}	d|	vrjd|	}	t�}
z
|
�t�|	��Wnty�}z|r�tt|��|�tt|��|�d}~wwt|
�d��}t|�}td
d�|��D�dd�|��D�B�}
dd�|��D�}t|�}g}|��D]$\}}|
�|d�}|�|�}|dD]}|
�|�}|�|||f�q�q�|p�i}|�dd�}|�dd�}|
||||d�}dt|�}|j}t|d�t|d||i�ttj ddd|d||fd �t�!tj t"d!�d"d#���S)$NrTr/�filezInvalid argument(s).z!The file %(file)s does not exist.)r��
css�|]}|��VqdSrn)�lstrip)r3�liner0r0r5r��r�z-WorkflowMacro.expand_macro.<locals>.<genexpr>�;z[ticket-workflow]z[ticket-workflow]
cSsh|]}|dD]}|�qqS)r%r0)r3rO�stater0r0r5r��s
�
�z-WorkflowMacro.expand_macro.<locals>.<setcomp>cSr�)r&r0)r3rOr0r0r5r��r7cSsg|]}|d�qS)r(r0)r3�attrsr0r0r5r6�r7z.WorkflowMacro.expand_macro.<locals>.<listcomp>r&r%�widthi �heightiX)�nodesrJ�edgesr�r�z%012xzcommon/js/workflow_graph.jszgraph_%sr$z!trac-workflow-graph trac-noscriptztrac-workflow-graph-%sz+display:inline-block;width:%spx;height:%spx)�class_r��stylez0Enable JavaScript to display the workflow graph.zsystem-message)r�)#r1rVrUr#rwr!�printrr{�read_file_by_pathrr�code�joinr<r�readfp�io�StringIOrr rrBrCrSr��indexrzr�r}rr�div�noscriptr)rh�	formatterr'�contentr�rW�is_macro�kwargsr�r��parser�erJ�states�
action_labels�action_namesr�rO�	new_index�
name_index�	old_state�	old_indexr�r��graph�graph_idr}r0r0r5�expand_macro~s�
�������

��
��
���zWorkflowMacro.expand_macrorn)r�r�r��_domainr�_descriptionrr0r0r0r5r�Bs�:r�);r�configparserrr�collectionsr�	functoolsr�
pkg_resourcesr�trac.apir�trac.configrr	r
�	trac.core�	trac.permrr
�
trac.resourcer�trac.ticket.apirr�trac.ticket.modelrr�r�	trac.utilrrrr�trac.util.htmlr�trac.util.presentationr�trac.util.translationrrr�trac.versioncontrol.apir�trac.web.chromerrr�trac.wiki.formatterr r!�trac.wiki.macrosr"r#rSrXr\r]r�r0r0r0r5�<module>s87	
O

https://t.me/RX1948 - 2025