HEX
Server: Apache
System: Linux pdx1-shared-a1-38 6.6.104-grsec-jammy+ #3 SMP Tue Sep 16 00:28:11 UTC 2025 x86_64
User: mmickelson (3396398)
PHP: 8.1.31
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/trac/versioncontrol/web_ui/__pycache__/util.cpython-310.pyc
o

�k�`m$�@s�ddlmZddlmZmZddlmZddlmZm	Z	ddl
mZddlm
Z
ddlmZmZddlmZmZmZdd	lmZgd
�ZGdd�de�Zddd�Zddd�Zdd�Zdd�Zdd�Zdd�Zd
S)�)�
TemporaryFile)�ZipFile�ZIP_DEFLATED)�ResourceNotFound)�content_disposition�create_zipinfo)�	http_date)�tag)�tag_�_)�EmptyChangeset�NoSuchChangeset�
NoSuchNode)�RequestDone)�content_closing�get_changes�get_path_links�get_existing_node�get_allowed_node�make_log_graph�
render_zipc@s$eZdZdd�Zdd�Zdd�ZdS)rcCs
||_dS�N��content)�selfr�r�A/usr/lib/python3/dist-packages/trac/versioncontrol/web_ui/util.py�__init__&s
zcontent_closing.__init__cCs|jSrr)rrrr�	__enter__)szcontent_closing.__enter__cGst|jd�r
|j��dSdS)N�close)�hasattrrr)r�exc_inforrr�__exit__,s�zcontent_closing.__exit__N)�__name__�
__module__�__qualname__rrr"rrrrr$srNc	Csli}|D]/}||vrqz|�|�}Wnty.t||�}|dur,|�d||jp*d�Ynw|||<q|S)Nz"Unable to get changeset [%s] in %sz	(default))�
get_changesetr
r�warning�reponame)�repos�revs�log�changes�rev�	changesetrrrr1s 
���
rc	Cs�|pd}d|j|dkr
|nd||d�d�g}|r'|�||j||||d�d��d}dd�|�d�D�D]}||d7}|�||j|pCd||||d�d��q3|S)Nzsource:�)r-�order�desc)�name�hrefcSsg|]}|r|�qSrr��.0�prrr�
<listcomp>Ksz"get_path_links.<locals>.<listcomp>�/)�browser�append�split)	r3r(�pathr-r0r1�links�partial_path�partrrrrAs*����
�rcCsvz|�||�WSty:}z'tjtd�|jj|jpd||dd�d�}tttj	|dd�t�	t
d|d�����d}~ww)	N�search�path_history)r-�mode)r3�message)�class_z^You can %(search)s in the repository history to see if that path existed but was later removed)r@)�get_noderr	�arr3r+r(rr6r
)�reqr)r<r-�e�search_arrrrUs 
������rc	CsH|dur z|�||�}WnttfyYdSw|�|�r"|SdSdSr)rErr
�is_viewable)r)r<r-�perm�noderrrrds�
�rcsg}g}d}t|�}dd�}z�t|�}d�g�g}	|}|�vr7|�dt���gg�|�|d���|�t|t���}��|��|��|�|��f�t|�}�dd�}	t|�|��}
�fdd�|
D�}||	��d	�<tt	�|��D]H\}\}
}|
|	vr�|||	�|
��d	�qx|
|kr�|r�|
�
|d�|
�|d�|
D]}||
dkr�|�d|�g�|||	�|��d	�q�qx|s�|�=n%t|�}|���fd
d�tt|�d	�D��||d�|�d	�d	�<|	��d	7�qt
y�Ynw|||fS)aGenerate graph information for the given revisions.

    Returns a tuple `(threads, vertices, columns)`, where:

     * `threads`: List of paint command lists `[(type, column, line)]`, where
       `type` is either 0 for "move to" or 1 for "line to", and `column` and
       `line` are coordinates.
     * `vertices`: List of `(column, thread_index)` tuples, where the `i`th
       item specifies the column in which to draw the dot in line `i` and the
       corresponding thread.
     * `columns`: Maximum width of the graph.
    rcSsP|r|ddd�d|gkr|dd|kr||dd<dS|�d||g�dS)N��������)r:)�thread�column�linerrr�add_edge�sz make_log_graph.<locals>.add_edgeTrMNcsg|]}|�vr|�qSrrr4)�activerrr7�sz"make_log_graph.<locals>.<listcomp>rOc3s(�|]}d�d|�dggVqdS)rrONr)r5�i)rRrSrr�	<genexpr>�s� �z!make_log_graph.<locals>.<genexpr>)�iter�nextr:�len�max�index�list�parent_revs�	enumerate�zip�remove�extend�range�
StopIteration)r)r*�threads�vertices�columnsrT�next_rev�
active_threadr-�	next_revs�parents�new_parents�col�rrQ�parent�baser)rUrRrSrrnsd


���+�
rcs��d���dd���dtd|��|r&��dt|j��|j�d�}nd}|r4|d7}|jd}nd}t|�}��	��fd	d
�}d}	t
dd
d���}
t|
dt���}||�D]�}||ur_qX|j�
d�}
|
�|�slJ�||
|d�}
d|ji}d}|jr�t|jdd���}|��}Wd�n1s�wY|��}d|vr�|�d�r�|dd�}d|d<d|vr�d|d<n|jr�|
r�d|d<d}|dur�|�t|
fi|��|�||
|	�}	qXWd�n1s�wY||
|	�Wd�t�1s�wYt�)a�Send a ZIP file containing the data corresponding to the `nodes`
    iterable.

    :type root_node: `~trac.versioncontrol.api.Node`
    :param root_node: optional ancestor for all the *nodes*

    :param iter_nodes: callable taking the optional *root_node* as input
                       and generating the `~trac.versioncontrol.api.Node`
                       for which the content should be added into the zip.
    ��zContent-Typezapplication/zipzContent-Disposition�inlinez
Last-Modifiedr8r/csb|��}|�|d�||}|dkr)|�t|d��}��|�|t|�8}|dks|�|d�|S)Nri)�tell�seek�read�min�writerZ)�fileobj�start�end�	remaining�chunk�rGrr�
write_partial�s
�z!render_zip.<locals>.write_partialrztrac-z.zip)�prefix�suffix�wN�mtime�CRLF)�eol_hintzsvn:specialzlink �T�symlinkzsvn:executable�
executable�dir)�
send_response�send_headerrr�
last_modifiedr<�rstripr2rZ�end_headersrrr�strip�
startswith�isfiler�get_processed_contentru�get_properties�isdir�writestrrr)rG�filenamer)�	root_node�
iter_nodes�	root_path�	root_name�root_lenr~�posrx�zipfilerLr<�kwargs�datar�propsrr}rr�sn
�

�
��

���
��rr)NN) �tempfilerr�rr�
trac.resourcer�	trac.utilrr�trac.util.datefmtr�trac.util.htmlr	�trac.util.translationr
r�trac.versioncontrol.apirr
r�trac.web.apir�__all__�objectrrrrrrrrrrr�<module>s"


N