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

�k�`)��@s�ddlZddlZddlZddlmZddlTddlmZddlm	Z	ddl
mZmZddl
mZddlmZdd	lmZmZdd
lmZmZmZddlmZddlmZdd
lmZmZmZm Z m!Z!ddl"m#Z#m$Z$ddl%m&Z&m'Z'm(Z(ddl)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3ddl4m5Z5m6Z6dZ7dZ8dd�Z9e�:dej;ej<B�Z=dd�Z>dd�Z?e�:dej;�Z@d dd�ZAGdd�deB�ZCdS)!�N)�	IntOption)�*)�get_column_names)�IPermissionRequestor)�Resource�ResourceNotFound)�TicketSystem)�Report)�as_int�content_disposition)�format_datetime�format_time�from_utimestamp)�tag)�	Paginator)�exception_to_unicode�quote_query_string�sub_vars�sub_vars_re�
to_unicode)�_�tag_)�HTTPBadRequest�IRequestHandler�RequestDone)
�Chrome�INavigationContributor�add_ctxtnav�add_link�
add_notice�add_script_data�add_stylesheet�add_warning�	auth_link�web_context)�IWikiSyntaxProvider�
WikiParserz
@SORT_COLUMN@z@LIMIT_OFFSET@cCs|dkrdS|rt|�SdS)z�Normalize a cell value for display.
    >>> (cell_value(None), cell_value(0), cell_value(1), cell_value('v'))
    ('', '0', '1', 'v')
    r�0�)�str)�v�r+�4/usr/lib/python3/dist-packages/trac/ticket/report.py�
cell_value1sr-z�
      --.*$                        # single line "--" comment
    | /\*([^*/]|\*[^/]|/[^*])*\*/  # C style comment
    | '(\\.|[^'\\])*'              # literal string
    | \([^()]+\)                   # parenthesis group
cCsdt|�d��S)N� r)�len�group)�mr+r+r,�_expand_with_spaceAsr2cCs(d}||kr|}t�t|�}||ks|S)a�Strip an SQL query to leave only its toplevel structure.

    This is probably not 100% robust but should be enough for most
    needs.

    >>> re.sub(r'\s+', lambda m: '<%d>' % len(m.group(0)), sql_skeleton('''\n        SELECT a FROM (SELECT x FROM z ORDER BY COALESCE(u, ')/*(')) ORDER \n          /* SELECT a FROM (SELECT x /* FROM z                             \n                        ORDER BY */ COALESCE(u, ')X(')) ORDER */           \n          BY c, (SELECT s FROM f WHERE v in ('ORDER BY', '(\')')          \n                 ORDER BY (1), '') -- LIMIT                                \n         '''))
    '<9>SELECT<1>a<1>FROM<48>ORDER<164>BY<1>c,<144>'
    N)�_sql_re�subr2)�sql�oldr+r+r,�sql_skeletonEs�r7z
ORDER\s+BYcCs\|durt|�}|�|���}t|�dkr*|dt|d��|t|d�d�fS|dfS)z�Split an SQL query according to a toplevel clause regexp.

    We assume there's only one such clause present in the outer query.

    >>> split_sql('''SELECT a FROM x  ORDER             BY u, v''', _order_by_re)
    ('SELECT a FROM x  ', ' u, v')
    N�r�r()r7�split�upperr/)r5�	clause_re�skel�blocksr+r+r,�	split_sql]s	*r?c@seZdZeeeee�ej	Z	e
dddd�Ze
dddd�ZdZ
d	d
�Zdd�Zd
d�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zhd!�Zd"d#�Zd:d$d%�Ze�d&ejej B�Z!d'd(�Z"d)d*�Z#d+d,�Z$	.	/d;d0d1�Z%d2d3�Z&d4d5�Z'd6d7�Z(d<d8d9�Z)d/S)=�ReportModule�report�items_per_page�dztNumber of tickets displayed per page in ticket reports,
        by default. Set to `0` to specify no limit.
        �items_per_page_rssrzjNumber of tickets displayed in the rss feeds for reports.
        Set to `0` to specify no limit.
        ���cCsdS)N�ticketsr+��self�reqr+r+r,�get_active_navigation_item�sz'ReportModule.get_active_navigation_itemccs>�d|�|j|j�vrddtjtd�|j��d�fVdSdS)N�REPORT_VIEW�mainnavrFzView Tickets��href)�perm�realm�REPORT_LIST_IDr�arrNrArGr+r+r,�get_navigation_items�s���z!ReportModule.get_navigation_itemscCsgd�}|d|fgS)N)�
REPORT_CREATE�
REPORT_DELETE�
REPORT_MODIFY�REPORT_SQL_VIEWrK�REPORT_ADMINr+)rH�actionsr+r+r,�get_permission_actions�sz#ReportModule.get_permission_actionscCs:t�d|j|j�}|r|�d�r|�d�|jd<dSdS)Nz/report(?:/(?:([0-9]+)|%s))?$r9�idT)�re�matchrQ�	path_infor0�args)rHrIr]r+r+r,�
match_request�s��
�zReportModule.match_requestc	Cs|j�d|j�}|�|j|��d�i}|j�dd�}d}|jdkrQ|dkr,|�|�n|dkr7|�	||�n
|dkrA|�
||�|d	krK|�|�nLtt
d
���|dvrad}|�|||d
k�}n6|dkrnd}|�||�}n)||jkr�|�|�\}}}|r�||d|ifSn|�||�\}}}|r�||d|ifSddlm}d|�tj�vo�|j�|�}||jks�|dkr�d|�|j|j�vr�t|t
d�|j��d�t|d|j��t
d��n	|r�t|t
d��|r�t|t
d�|j��d�|j��|d<|j�d�|d<nd|d<t|d�||fS)Nr[rK�action�view�POST�new�delete�edit�clearzInvalid request arguments.)�copyrfrdzreport_edit.htmlrhzreport_delete.html�content_typer)�QueryModule�TICKET_VIEWzAvailable ReportsrM�upzNew Custom Query�
query_href�saved_query_hrefzcommon/css/report.css)r_�getintrQrOrP�require�get�method�
_do_create�
_do_delete�_do_save�	_do_clearrr�_render_editor�_render_confirm_delete�_render_list�_render_view�trac.ticket.queryrjr�env�is_component_enabledrrNrAr�query�sessionr!)	rHrIr[�datara�templaterirj�show_query_linkr+r+r,�process_request�s\

�
�
zReportModule.process_requestcCs�|�|j��d�d|jvr|�|j���t|j�}|j�	dd�|_
|j�	dd�|_|j�	dd�|_|�
�t|td��|�|j�|j��dS)NrT�cancel�titler(r~�descriptionzThe report has been created.)rOrPrpr_�redirectrNrAr	r|rqr�r~r��insertrrr[)rHrIrAr+r+r,rs�s

zReportModule._do_createcCsf|�|j|��d�d|jvr|�|j�|��t|j|��	�t
|td|d��|�|j���dS)NrUr�z%The report {%(id)d} has been deleted.)r[)rOrPrpr_r�rNrAr	r|rerr)rHrIr[r+r+r,rt�s
zReportModule._do_deletecCs�|�|j|��d�d|jvr8t|j|�}|j�dd�|_|j�dd�|_|j�dd�|_	|�
�t|td��|�
|j�|��dS)	z#Save report changes to the databaserVr�r�r(r~r�zYour changes have been saved.N)rOrPrpr_r	r|rqr�r~r��updaterrr�rNrA)rHrIr[rAr+r+r,ru�s
zReportModule._do_savecCs0dD]}||jvr
|j|=q|�|j���dS)N)rm�
query_tickets)rr�rNrA)rHrI�namer+r+r,rv�s

�zReportModule._do_clearcCs>|�|j|��d�t|j|�j}td||d�d||d�d�S)NrUz!Delete Report {%(num)s} %(title)s)�numr�re)r[r�)r�rarA)rOrPrpr	r|r�r)rHrIr[r�r+r+r,rxs��z#ReportModule._render_confirm_deletec
Cs�||jkr!|�|j|��d�t|j|�}|j|j|j}}}n|�|j��d�d}}}|j	�
d|�}|r=|d7}|sD||jkrJddd�}n	d|j	�
d	�d�}||||d
�|d<t|j�}	|	�|�|	�
|�|S)NrVrTr(r~z (copy)rd�ra�errorrfr�)r[r�r5r�rA)rQrOrPrpr	r|r�r�r~r_rqr�add_wiki_toolbars�add_auto_preview)
rHrIr[rh�rr�r�r~r��chromer+r+r,rws.
�
�
�


zReportModule._render_editorcs>�j�dd�}�jjddddd���j�d�}��fdd	�t��j|t���D�}|d
kr6d|i}d|d
fS|dkrG�j�gd�|ddd�n|dkrX�j�gd�|dddd���fdd�}t�dt	�|d
d��t
d�d
d
�t�d|dd�t
d�d�t�d|dd�t
d�d���fdd	�|D�}||�d �}d!|d"fS)#z%Render the list of available reports.�sortrA�ascr9r��min�max�formatcs0g|]}d���j|j�vr|j|j|jf�qS)rK)rOrPr[r�r�)�.0rA�rIrHr+r,�
<listcomp>0s
�z-ReportModule._render_list.<locals>.<listcomp>�rss�rowszreport_list.rss�application/rss+xml�csv)rAr�r��text/csvzreports.csv��mimetype�filename�tab�	�text/tab-separated-valueszreports.tsvcs �jjd�j�d��d�|��S)Nr�)r�r�r+)rNrAr_rq)�kwargs)r�rIr+r,�report_href@s�z.ReportModule._render_list.<locals>.report_href�	alternate)r��RSS Feed�Comma-delimited Text�
text/plain�Tab-delimited Textcs<g|]\}}}|||d���j|�vd���j|�vf�qS)rVrU)rOrP)r�r[r�r�r�r+r,r�Ls��)�reportsr�r�zreport_list.htmlN)r_rqror	�selectr|�bool�	_send_csvrr#r)rHrIr�r�r�r�r�r�r+)r�rIrHr,ry*sF�
��
����
zReportModule._render_list>�	__class__�	__color__�	__style__�__bgcolor__�__fgcolor__�
__grouplink__cAs�
t|j��}|j|j|j}}}d�dd�|��D��}|rr|ddks*|�d�rr|ddkr2|n|dd�}d	�}d
|vrW||vrVtd�d�}	��	�j
j�d
|	d��n|ddkra|d7}||7}��	�j
��t|��nF|�d�r�ddl
m}
m}z|
j|j|dd��d�}Wn |y�}z��	�j
j�d
t|�d��WYd}~nd}~ww��	|��j
���j�d�}
|
dkr�|���|||�d�|f}t|j��}��|��d�t�|�}�j�dd��|jddd��|
|j���j�d��t��dd�}�d|}�j�dd��	�jjddddd��i���������	fd d!�}d"�|d#�||||�d$dd|d%�}z
|����|� �|�}Wn t!�yh}ztd&|d'�|d(<d)|dfWYd}~Sd}~ww|�"�t#|��t#|�pud��d*��z|�$��|�||�}Wnt%�y�}ztd&|d'�|d(<WYd}~n(d}~wwt&|�d+k�r�|\}}t'd,t(�)t*|��t(t(�+�t(j)|d-d.��d/�|d(<|d(�r�d)|dfS|\}}}}}|dk�o�|}|du}d0d1�|D�}t&|�}d}|�r`t,|�d||�}||d2<|j-�rt.�d3|�dd4�td5��|j/�r#t.�d6|�dd4�td7��g}|�0d8�}|D]} |�1|| d4�dt2| �td9| d�g��q,gd:���fd;d1�|D�|_3dd<t2|j4d�dd:�|_5|j6}t7|j��8�}!gg}"t9|�D]�\�}#|#|!v�r||!|#}n|#�:d=��;�}|#|d$dd>�}$|#�	k�r��r��|d<�	|d<t<��|$d<|�s�|�r�i�
�	d?v�r�|jj=�}%|%d@|%�>dAdB��	f�D]	\}&}'|'�
|&<�q�Wd�n	1�s�wY��
fdCdD�}(t?||(�dE�}|"d})|#�dF��r�|#�@dF��r�dG|$dH<n3|#dd=k�r|#dd=k�rg})|"�1|)�|"�1g�n|#dd=k�r#dG|$dH<n|#dd=k�r/|"�1g�|)�1|$��qntA|j�}*g}+g},d}-t9|�D]�\}.}/d}0g}1dI|1i}2t7j}3d}4d}5g}6|"D]�})g}7|)D]t}$tB|/|0�}'|'|$|0dJ�}8|$dK}#|0d7}0|#dLk�r�|'|-k�r�|'}-|+�1|'�o�|*�C�|'�gf�|.|2dM<|#|jDv�r�|'|2|#<|#dNv�r�|'|2dO<|#�:d=�}#|#dPv�r�|6�1|8�n|#dQk�r�|'}3n|#dRk�r�|'}4n|#dSk�r�|'}5|7�1|8��qb|1�1|7��q\|4�r�t|3|2�dO�t|4|5�dT�}9nt|3|2�dO��}9|9j�E�dU��|9�v�r�qE|,�1|/�|6�r)|6D]}8|*�F|�G|9�|8dA�}:|:|/|8dV<|8dA<�q|9|2dW<|+�r7|+dd};ng};d|;fg}+|;�1|2��qE|�"|"|+|dX��|
dYk�rat�|dGdZ�|d[<d\|d]fS|
d^k�r{��rmd_�nd`}<|jH�||,da|<db�dS|
dck�r���r�dd�nde}<|jH�||,dfdg|<db�dS�du�r��nd} t.�dhtI�|dYddi��tdj�d]dY�t.�dh|d^| di�tdk�dl�t.�dh|dc| di�tdm�dl�dn��|j��v�r�t.�dh�j
j�ddo�tdp�dl�z*dq�drd�|+D���jJds<|��jJdt<�jJdt<duD]
}=|=�jJv�r�jJ|==�qWnt!tKf�yYnwtL|dv�dwh�rjdG|dx<t7|j��M��i}>tL|dv�dwhD]}?��N|?�O��}@|@�rWdy|@v�rW|@dy|>|@dz<�q>|>�rjtP�|>d{�tA|j��Q��|�rytR�td|d}�|�d~��d)|dfS)z?Retrieve the report results and pre-process them for rendering.r(css�|]}|��VqdS�N)�strip)r��liner+r+r,�	<genexpr>cs�z,ReportModule._render_view.<locals>.<genexpr>r�?zquery:?�Nz	report=%szreport=z6When specified, the report number should be "%(num)s".�r�rfr�rE�&zquery:)�Query�QuerySyntaxError)rAr�r5z{%i} %srK�pager9)r�r�r�r�)r�r�r�r�csd���}�r
�|d<�dkr�|d<��kr�|d<|�|�|�d��r'dnd|d<�j��|�S)zsGenerate links to this report preserving user variables,
            and sorting and paging variables.
            r�r9r�r�r�N)rhr�rqrNrA)r��params)r_r��default_maxr[r�r�rI�sort_colr+r,r��s
z.ReportModule._render_view.<locals>.report_hrefrb)r[�resourceF)rarA�contextr�r�r�r_�show_args_form�message�	paginatorr�zReport failed: %(error)s)r�r�zreport_view.html)r_r�r�r8z*Report execution failed: %(error)s %(sql)szwhite-space: pre)�style)r�r5cSsg|]}t|��qSr+)�list)r��rowr+r+r,r���z-ReportModule._render_view.<locals>.<listcomp>r��next)r�z	Next Page�prevz
Previous Page�zPage %(num)d)rN�class�stringr�csg|]	}tt�|���qSr+)�dict�zip�r��p)�fieldsr+r,r����currentr)�colr��hiddenr�)�status�
resolution�priority�severityz(SELECT name, %s FROM enum WHERE type=%%s�value�intcs,|�}�r��|�St|t�r|��}|Sr�)rq�
isinstancer)�lower)r��val)�idx�sort_valuesr+r,�sortkeys

z*ReportModule._render_view.<locals>.sortkey)�key�reverse�__Tr��cell_groups)r��header�indexr��	__group__�__idx__)rA�ticketr[�_idr[)�reporter�cc�ownerrP�parent_realm�	parent_id)�parent�_VIEWr�r�)�
header_groups�
row_groups�numrowsr�)�absurlsr�z
report.rssr�r�z
report_%s.csvz
report.csvr�r�r�z
report_%s.tsvz
report.tsvr�r�r�)r�r�r�r�r�r�rW)r[r�z	SQL Queryr.css.�|]}|dD]}tt|d��VqqdS)r9r[N)r)r�)r��rgr�r+r+r,r��s���r�rm)�query_constraints�
query_timer_�USERr��optionsr�)�
arg_valuesz-The following arguments are missing: %(args)s�, )r_)Sr	r|r�r�r~�join�
splitlines�
startswithrr�rNrArr{r�r��from_stringr�get_hrefr_rq�	_send_sqlrrPrOrpr$rorDrBr
�get_var_args�get_default_var_args�
ValueErrorr�r�execute_paginated_report�	TracErrorr/rr�prer�hrr�
has_next_pager�has_previous_page�get_shown_pages�appendr)�shown_pagesr��current_page�	num_itemsr�get_ticket_field_labels�	enumerater��
capitalizer��db_query�cast�sorted�endswithrr-�
format_author�
_html_colsr;�
format_emails�childr�r#r�KeyError�set�get_ticket_fields�by_namer�r �
add_jquery_uir")ArHrIr[r�r�r�r5r~�	report_id�errr�r��er��report_resourcer��limit�offsetr�r��res�cols�resultsr�missing_args�limit_offset�need_paginator�need_reorderr�r��pagedatarr��field_labelsr�r�r��dbr�r�r��header_groupr�r��authorized_results�prev_group_value�row_idx�result�col_idxr�r�rPr�r��email_cells�
cell_group�cellr��emails�	row_groupr��varr�arg�attrsr+)r_r�r�r�r[r�r�r�rIr�r�r,rzWsD	��
���
�
��
���������

��


��

�



����	




��





�
�
�

�


�

�
����
��
������
zReportModule._render_viewcCs|�||�\}}}|sttd|d���|j�d||�|j�d|j�d}d}	g}
d}|�td��td�}|j	j
���}
|
��}||jksH|dkrL|}�nTd	|}|j�d
||�z|�
||�Wn+ty�}z|j�d|||t|dd
��||fWYd}~Wd�Sd}~ww|��d}	d|}|j�d||�z|�
||�Wn+ty�}z|j�d|||t|dd
��||fWYd}~Wd�Sd}~wwt|�}|j�dd�}|jjddddd�}|j�d|||r�dnd�g}|�r||v�rttd|d���d}d|v�r|�d�|�r#d|
�|�|�rdndf}t|v�r2|�t|�p/d�}n1|�rcd|v�r?|
�d�|
�|�t|�}t|t|�\}}|�rX|
�|�d�|d d!�|
�g�}d}|	|k�rwd�d"t|�d#t|�g�}t|v�r�|�t|�}n|�p�t|�}d"|��v�r�d�||g�}|j�d$||�z|�
||�Wn<t�y�}z/|j�d|||t|dd
��|
�s�|�r�t|td%ttd&��||fWYd}~Wd�Sd}~ww|���p�g}t|�}Wd�n	1�s�wY|||	||fS)'aC
        :param req: `Request` object.
        :param id: Integer id of the report.
        :param sql: SQL query that generates the report.
        :param args: SQL query arguments.
        :param limit: Maximum number of results to return (optional).
        :param offset: Offset to start of results (optional).
        z"Report {%(num)s} has no SQL query.r�zReport {%d} with SQL "%s"zRequest args: %rNr�1r(z"SELECT COUNT(*) FROM (
%s
) AS tabzReport {%d} SQL (count): %sz;Exception caught while executing Report {%d}: %r, args %r%sT)�	tracebackz#SELECT * FROM (
%s
) AS tab LIMIT 1zReport {%d} SQL (col names): %sz7Exception caught while executing Report {%d}: args %r%sr�r�r9r�z
%r %s (%s)�^r*z/Query parameter "sort=%(sort_col)s"  is invalid)r�r�z%s %s�ASC�DESCz
__group__ ASCr.zORDER BYr�LIMIT�OFFSETz#Report {%d} SQL (order + limit): %sz�Hint: if the report failed due to automatic modification of the ORDER BY clause or the addition of LIMIT/OFFSET, please look up %(sort_column)s and %(limit_offset)s in TracReports to see how to gain complete control over report rewriting.)�sort_columnr3)�sql_sub_varsrr�log�debugr_�replace�SORT_COLUMN�LIMIT_OFFSETr|r�cursorrQ�execute�	Exception�warningr�fetchonerrqror�quoter7r?�_order_by_rerr)r;r�fetchall)rHrIr[r5r_r-r.r2r�r�order_byr3�base_sqlr8rU�	count_sqlr+�colnames_sqlr0r�r��
order_colsr=�before�afterr+r+r,r�s�	
���
��
���
��


�





�

��
��Q
�dz%ReportModule.execute_paginated_reportz%^\s*--\s*(\w*)[ ]*=[ ]*([^\r\n]*)\r?$cCsDi}|jD]}|��sqt|j�|��||<qd|vr |j|d<|S)Nr)r_�isupperrrq�authname)rHrI�report_argsrEr+r+r,r%s

zReportModule.get_var_argscs�fdd�}|j�||�S)Ncs��|�d�|�d��dS)Nr9r8)�
setdefaultr0)�	fullmatch�rfr+r,�extract_default_var4sz>ReportModule.get_default_var_args.<locals>.extract_default_var)�arg_default_rer4)rHrfr5rjr+rir,r3sz!ReportModule.get_default_var_argsc	s�t��g�g�����fdd���fdd�}�fdd�}t��}|jj�(}t�d|�D]}|�d�r;|�|||��q+|�t	�
||��q+Wd	�n1sOwYt���D]}�|=qZ|����fS)
z;Extract $XYZ-style variables from the `sql` query.
        csz��|�z�|}|�d�r|dd�}|�d�s�|}Wnty5d}�t|�<��|�Ynw��|�dS)N�$r9r()�addrr$r)r)�anamerE)r_r2�names�valuesr+r,�	add_value?s


��z,ReportModule.sql_sub_vars.<locals>.add_valuecs�|�d��dS)Nr9�%s)r0)r]�rqr+r,�replNsz'ReportModule.sql_sub_vars.<locals>.replcsrt�|dd��}t|�dkr|S|ddd�}dd�|D�}dgt|�|ddd�<|D]}�|�q-|j|�S)Nr9rEr8cSsg|]}d|�qS)z'%s'r+r�r+r+r,r�Xr�zCReportModule.sql_sub_vars.<locals>.repl_literal.<locals>.<listcomp>rr)rr:r/�concat)�exprr8�partsr��paramrsr+r,�repl_literalSs

z/ReportModule.sql_sub_vars.<locals>.repl_literalz('(?:[^']|(?:''))*')�'N)r%�io�StringIOr|rr\r:r�writerr4�getvalue)	rHr5r_rtry�sql_ior8rvr�r+)rqr_r2rorpr,rO8s"

��zReportModule.sql_sub_vars�,r�Ncs�dd�}dd�}||||||d�������fdd�}	|	�}
t�j�jr'd}n	d�|
�}
t|
�}|�d	�|�d
|d�|durG|�d|�|rR|�d
td|��|��|�	|
�t
�)NcS�tt|�d�S�N�iso8601)r
r)�tr+r+r,�iso_timep�z(ReportModule._send_csv.<locals>.iso_timecSr�r�)rr)�dtr+r+r,�iso_datetimesr�z,ReportModule._send_csv.<locals>.iso_datetime)�time�datetime�
changetime�date�created�modifiedc3s��t���tjtj�dddd��tjd����fdd�}�fdd	��D��d
V|�fdd��D��V�D]}|���fd
d�t|�D��Vq6dS)N�utf-8�
T)�encoding�newline�
write_through)�	delimiter�quotingcs*��|����}��d���d�|S)Nr)�writerowr~�truncate�seek)rp�rv)�out�writerr+r,r��s



z9ReportModule._send_csv.<locals>.iterate.<locals>.writerowcsg|]}��|�d�t��qS)r)rqr�r-�r��c)�col_conversionsr+r,r��s�z;ReportModule._send_csv.<locals>.iterate.<locals>.<listcomp>sc3s�|]
}|�jvr|VqdSr��r!r��rHr+r,r��s�z:ReportModule._send_csv.<locals>.iterate.<locals>.<genexpr>c3s.�|]\}}�|�jvr�||�VqdSr�r�)r��irA)r0�
convertersrHr+r,r��s�
��)r{�BytesIOr�r��
TextIOWrapper�
QUOTE_MINIMALr)r�r��r�r0r�rH�sep)r�r�r�r,�iterates&���
���z'ReportModule._send_csv.<locals>.iterate����Content-Typez;charset=utf-8�Content-Length�Content-Disposition�
attachment)rr|�use_chunked_encodingrr/�
send_response�send_headerr�end_headersr}r)rHrIr0r�r�r�r�r�r�r�r��lengthr+r�r,r�ns4�	

�
zReportModule._send_csvc	Cs�|�|j|��d�t��}|�d||�d�f�|r-|�d���}|�dd�|��|�|�d��|�	�}|�
d�|�dd�|�d	t|��|rY|�d
t
dd|��|��|�|�t�)
NrWs-- ## %s: %s ## --

r�s-- %s

z
-- r�r�ztext/plain;charset=utf-8r�r�r�z
report_%s.sql)rOrPrpr{r�r}�encoderrr~r�r�r/rr�r)	rHrIr[r�r�r5r��linesr�r+r+r,r
�s(
��
zReportModule._send_sqlccs�d|jfVdS)NrA��_format_linkr�r+r+r,�get_link_resolvers�s�zReportModule.get_link_resolversc#s�dtj�fdd�fVdS)Nz !?\{(?P<it_report>%s\s*)[0-9]+\}cs��|d|dd�||�S)NrAr9rEr�)�x�y�zr�r+r,�<lambda>�r�z.ReportModule.get_wiki_syntax.<locals>.<lambda>)r&�INTERTRAC_SCHEMEr�r+r�r,�get_wiki_syntax�s��

�zReportModule.get_wiki_syntaxc
Cs�|�||||�}|r|S|�|�\}}}	zt|j|�Wnty/tj|dtd�d�YSwd|j�	|j
|�vrHtj||j�|�|dd�Stj|dtd�d�S)	Nzmissing reportzreport does not exist)�class_r�rKrA)rNr�zforbidden reportzno permission to view report)
�shorthand_intertrac_helper�
split_linkr	r|rrrRrrIrOrPrNrA)
rH�	formatter�ns�target�labelrh�	intertracr[r_�fragmentr+r+r,r��s(
�
����zReportModule._format_link)rr)r�r�Nr�)*�__name__�
__module__�__qualname__�
implementsrrrr%r	rPrrBrDrQrJrSrZr`r�rsrtrurvrxrwryr!rzrr\�compile�	MULTILINE�UNICODErkrrrOr�r
r�r�r�r+r+r+r,r@osV���;

	*
M
�6
�:r@r�)Dr�r{r\�trac.configr�	trac.core�trac.db.apir�	trac.permr�
trac.resourcerr�trac.ticket.apir�trac.ticket.modelr	�	trac.utilr
r�trac.util.datefmtrr
r�trac.util.htmlr�trac.util.presentationr�trac.util.textrrrrr�trac.util.translationrr�trac.web.apirrr�trac.web.chromerrrrrr r!r"r#r$�	trac.wikir%r&rSrTr-r�r��VERBOSEr3r2r7r[r?�	Componentr@r+r+r+r,�<module>s<0
�


https://t.me/RX1948 - 2025