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/docutils/parsers/rst/directives/__pycache__/tables.cpython-310.pyc
o

�?�]Y�@s�dZdZddlZddlZddlZddlmZmZm	Z	m
Z
ddlmZddl
mZddlmZddlmZd	d
�ZGdd�de�ZGd
d�de�ZGdd�de�ZGdd�de�ZdS)z 
Directives for table elements.
�reStructuredText�N)�io�nodes�statemachine�utils)�
SafeString)�SystemMessagePropagation)�	Directive)�
directivescCst�|d�S)N)�left�center�right)r
�choice)�argument�r�H/usr/lib/python3/dist-packages/docutils/parsers/rst/directives/tables.py�alignsrc@sxeZdZdZdZdZejeje	ej
e�dej�d�Z
dZdd�Zdd	�Zd
d�Zdd
�Zedd��Zdd�Zdd�ZdS)�Tablez#
    Generic table base class.
    �T)�auto�grid)�class�namer�width�widthscCsf|jr+|jd}|j�||j�\}}tj|dg|�R�}|j�|j�\|_|_	||fSd}g}||fS)Nr�)
�	arguments�state�inline_text�linenor�title�
state_machine�get_source_and_line�source�line)�self�
title_text�
text_nodes�messagesr rrr�
make_title+s
���zTable.make_titlecCsX|j�|jd�}g}d}d|jvr(|�|jd�d�|��|�\}}|�|�||fS)Nrr�header�
)r!�
get_sourcer�options�parse_csv_data_into_rows�split�
HeaderDialect�extend)r%r#�
table_head�max_header_cols�rowsrrr�process_header_option8s
�
zTable.process_header_optioncCsBt|�|kr#|jjjd|t|�|jft�|j|j�|jd�}t	|��t|�|kr/dkrMnn|jjjdt|�|jft�|j|j�|jd�}t	|��|D]O}t|�|krt|jjjd|t|�|jft�|j|j�|jd�}t	|��t|�|kr�dkr�nqO|jjjdt|�|jft�|j|j�|jd�}t	|��qOdS)NzP%s header row(s) specified but only %s row(s) of data supplied ("%s" directive).�r$rzeInsufficient data supplied (%s row(s)); no data remaining for table body, required by "%s" directive.zU%s stub column(s) specified but only %s columns(s) of data supplied ("%s" directive).ziInsufficient data supplied (%s columns(s)); no data remaining for table body, required by "%s" directive.)
�lenr!�reporter�errorrr�
literal_block�
block_textrr)r%r4�header_rows�stub_columnsr9�rowrrr�check_table_dimensionsCs^��������������zTable.check_table_dimensionscCs"d|jvr|j�d�|d<dSdS)Nr�r-�get)r%�
table_noderrr�set_table_widthbs
�zTable.set_table_widthcCs|j�dd�S)Nrrr@�r%rrrrfszTable.widthscCs�t|jt�r,t|j�|kr'|jjjd|j|ft�	|j
|j
�|jd�}t|��|j}|S|r7d|g|}|S|jjjdt�	|j
|j
�|jd�}t|��)Nz="%s" widths do not match the number of columns in table (%s).r6�dz#No table data detected in CSV file.)
�
isinstancer�listr7r!r8r9rrr:r;rr)r%�max_colsr9�
col_widthsrrr�get_column_widthsjs0�������zTable.get_column_widthscCsD|D]}|D]}t|�|kr|�dddgfg|t|��qqdS)Nr)r7r1)r%�columns�parts�partr>rrr�"extend_short_rows_with_empty_cells|s ���z(Table.extend_short_rows_with_empty_cellsN)�__name__�
__module__�__qualname__�__doc__�optional_arguments�final_argument_whitespacer
�class_option�	unchangedr� length_or_percentage_or_unitless�value_or�positive_int_list�option_spec�has_contentr)r5r?rC�propertyrrJrNrrrrrs*��

rc@seZdZdd�ZdS)�RSTTablecCs�|js|jjjd|jt�|j|j�|jd�}|gS|�	�\}}t�
�}|j�|j|j
|�t|�dks<t|dtj�sS|jjjd|jt�|j|j�|jd�}|gS|d}|d|j�dg�7<|�|�d|jvrv|j�d�|d<|d}t|jt�r�d	d
�|jD�}t||j�D]\}	}
|
|	d<q�|jdkr�|dd
g7<n|jr�|ddg7<|�|�|r�|�d|�|g|S)Nz:Content block expected for the "%s" directive; none found.r6rrzOError parsing content block for the "%s" directive: exactly one table expected.�classesrrcSsg|]	}|jdkr|�qS)�colspec)�tagname)�.0�childrrr�
<listcomp>�s
�z RSTTable.run.<locals>.<listcomp>�colwidthr�colwidths-auto�colwidths-given)�contentr!r8�warningrrr:r;rr)�Elementr�nested_parse�content_offsetr7rF�tabler9r-rArCrrG�children�zip�add_name�insert)r%rhr r(�noder9rB�tgroup�colspecsr_�	col_widthrrr�run�sV������





zRSTTable.runN)rOrPrQrurrrrr]�sr]c@s�eZdZejejejeje�dej�ej	ej
ejejeje
ejejejejd�ZGdd�dej�ZGdd�dej�Zdd�Zd	d
�Zdd�Zejd
krTdd�Zdd�Zndd�Zdd�Zee�Zee�Zdd�ZdS)�CSVTable�r)�header-rows�stub-columnsr*rr�file�url�encodingrrr�delim�	keepspace�quote�escapec@s6eZdZdZdZdZdZdZdZdZ	e
jZdd�Z
dS)	zCSVTable.DocutilsDialectz&CSV dialect for `csv_table` directive.�,�"Tr+cCsld|vrt�|d�|_d|vrd|_d|vrt�|d�|_d|vr.d|_t�|d�|_tj�	|�dS)Nr}r~Frr�)
rv�encode_for_csv�	delimiter�skipinitialspace�	quotechar�doublequote�
escapechar�csv�Dialect�__init__)r%r-rrrr��sz!CSVTable.DocutilsDialect.__init__N)rOrPrQrRr�r�r�r��strict�lineterminatorr��
QUOTE_MINIMAL�quotingr�rrrr�DocutilsDialect�sr�c@s2eZdZdZdZdZdZdZdZdZ	dZ
ejZ
dS)	zCSVTable.HeaderDialectz0CSV dialect to use for the "header" option data.r�r��\FTr+N)rOrPrQrRr�r�r�r�r�r�r�r�r�r�rrrrr0�s
r0cCsdS�NrrDrrr�check_requirements��zCSVTable.check_requirementsc
Cs8z�|jjjjs)d|jvsd|jvr)|jjjd|jt	�
|j|j�|jd�}|gWS|�
�|��\}}|��\}}|��\}}|�||�|j�|�\}}	t|	|�}	|j�dd�}
|j�dd�}|�||
|�|�|d|
��||
d�}|�|	�}
|�|	||f�WnTty�}z|jdgWYd}~Sd}~wtjy�}z0t|�}tjdkr�d	|vr�|d
7}|jjj d|j|ft	�
|j|j�|jd�}|gWYd}~Sd}~ww|
||f}|jj!||j"||j#d�}|d
|j�dg�7<d|jv�r|j�d�|d<|�$|�|�%|�|�r|�&d|�|g|S)Nrzr{z9File and URL access deactivated; ignoring "%s" directive.r6rxrry��rz1-character stringz1
with Python 2.x this must be an ASCII character.z)Error with CSV data in "%s" directive:
%s)rr^rr)'r�document�settings�file_insertion_enabledr-r!r8rhrrr:r;rr�r)�get_csv_datar5r.r��maxrAr?r1rJrNr�argsr��Error�str�sys�version_infor9�build_tablerkrrCrorp)r%rhr r(�csv_datar#r2r3r4rHr<r=�
table_bodyrI�detail�messager9rlrBrrrru�s|

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


zCSVTable.runcCs�|j�d|jjjj�}|jjjj}|jrCd|jvsd|jvr6|jj	j
d|jt�
|j|j�|jd�}t|��|j�d�}|j}||fSd|jvr�d|jvre|jj	j
d|jt�
|j|j�|jd�}t|��tj�tj�|jjj��}tj�tj�||jd��}t�d|�}z|jjjj�|�tj|||d	�}|��� �}W||fSt!y�}z|jj	j"d
|jt#|�ft�
|j|j�|jd�}t|��d}~wwd|jv�rAt$j%dkr�ddl&m'}	dd
l(m)}
nddl*m'}	m)}
|jd}z|	|���}Wn1|
t!t+t,f�y)}z |jj	j"d|j|jdt#|�ft�
|j|j�|jd�}t|��d}~wwtj-||||jjjjd�}|��� �}||fS|jj	j.d|jt�
|j|j�|jd�}t|��)zr
        Get CSV data from the directive content, from an external
        file, or from a URL reference.
        r|rzr{zF"%s" directive may not both specify an external file and have content.r6rzXThe "file" and "url" options may not be simultaneously specified for the "%s" directive.N)�source_pathr|�
error_handlerz&Problems with "%s" directive path:
%s.r�)�urlopen)�URLError)r�r�z*Problems with "%s" directive URL "%s":
%s.)r#r�r|r�z3The "%s" directive requires content; none supplied.)/r-rArr�r��input_encoding�input_encoding_error_handlerrgr!r8r9rrr:r;rrr#�os�path�dirname�abspath�current_source�normpath�joinr�
relative_path�record_dependencies�addr�	FileInput�read�
splitlines�IOError�severerr�r��urllib.requestr��urllib.errorr��urllib2�OSError�
ValueError�StringInputrh)r%r|r�r9r#r��
source_dir�csv_filer�r�r��csv_textrrrr�s�����<
�
�����(�����

���������zCSVTable.get_csv_datar�cC�
|�d�S�Nzutf-8)�decode��srrr�decode_from_csvn�
zCSVTable.decode_from_csvcCr�r�)�encoder�rrrr�pr�zCSVTable.encode_for_csvcC�|Sr�rr�rrrr�sr�cCr�r�rr�rrrr�ur�c	s�tj�fdd�|D�|d�}g}d}|D],}g}|D]}	��|	�}
dddtj|
��|d�f}|�|�q|�|�t|t|��}q||fS)Ncsg|]	}��|d��qS)r+)r�)rar$rDrrrc|s�z5CSVTable.parse_csv_data_into_rows.<locals>.<listcomp>)�dialectr)r#)	r��readerr�r�
StringListr��appendr�r7)r%r�r�r#�
csv_readerr4rHr>�row_data�cell�	cell_text�	cell_datarrDrr.zs$��

�
z!CSVTable.parse_csv_data_into_rowsN)rOrPrQr
�nonnegative_intrVrWrXrYr��urir|rUr�$single_char_or_whitespace_or_unicode�flag�single_char_or_unicoderZr�r�r�r0r�rur�r�r�r�r��staticmethodr.rrrrrv�s@��
0
O
rvc@sPeZdZdZejejeje�dej�ej	ej
ed�Zdd�Z
dd�Zdd	�Zd
S)�	ListTablez�
    Implement tables whose data is encoded as a uniform two-level bullet list.
    For further ideas, see
    http://docutils.sf.net/docs/dev/rst/alternatives.html#list-driven-tables
    rw)rxryrrrrrc
CsN|js|jjjd|jt�|j|j�|jd�}|gS|�	�\}}t�
�}|j�|j|j
|�z'|�|�\}}dd�|dD�}|j�dd�}|j�dd�}	|�|||	�Wntym}
z|
jdgWYd}
~
Sd}
~
ww|�||||	�}d|jvr�|j�d�|d<|d	|j�d
g�7<|�|�|�|�|r�|�d|�|g|S)Nz.The "%s" directive is empty; content required.r6cSsg|]}dd�|dD��qS)cSsg|]}|j�qSr)rm)ra�itemrrrrc�sz,ListTable.run.<locals>.<listcomp>.<listcomp>rr)ra�row_listrrrrc�s�z!ListTable.run.<locals>.<listcomp>rrxryrr^r)rgr!r8r9rrr:r;rr)rirrjrk�check_list_contentr-rAr?rr��build_table_from_listrCrorp)r%r9r r(rq�num_colsrI�
table_datar<r=r�rBrrrru�sB�����



z
ListTable.runcCs>t|�dkst|dtj�s&|jjjd|jt�|j	|j	�|j
d�}t|��|d}d}tt|��D]c}||}t|�dksFt|dtj�sb|jjjd|j|dft�|j	|j	�|j
d�}t|��|r�t|d�|kr�|jjjd|j|dt|d�|ft�|j	|j	�|j
d�}t|��q2t|d�}q2|�
|�}||fS)NrrzUError parsing content block for the "%s" directive: exactly one bullet list expected.r6z�Error parsing content block for the "%s" directive: two-level bullet list expected, but row %s does not contain a second-level bullet list.z�Error parsing content block for the "%s" directive: uniform two-level bullet list expected, but row %s does not contain the same number of items as row 1 (%s vs %s).)r7rFr�bullet_listr!r8r9rr:r;rr�rangerJ)r%rqr9�	list_noder��
item_indexr�rIrrrr��sL��������
zListTable.check_list_contentcCs&t��}|jdkr|ddg7<n|jr|ddg7<tjt|�d�}||7}|D]}t��}|dur<||jd<|rGd|jd<|d8}||7}q-g}	|D]}
t��}|
D]}t��}
|
|7}
||
7}qX|	�	|�qP|r�t�
�}|�|	d|��||7}t��}|�|	|d��||7}|S)	Nrr^rerf)�colsrdr�stub)
rrlrrrr7r_�
attributesr>�entryr��theadr1�tbody)r%r�rIr<r=rlrrrtr_r4r>�row_noder�r�r�r�rrrr��s>




zListTable.build_table_from_listN)rOrPrQrRr
r�rWrXrYrUrVrrZrur�r�rrrrr��s��	%r�)rR�
__docformat__r��os.pathr�r��docutilsrrrr�docutils.utils.error_reportingr�docutils.utilsr�docutils.parsers.rstr	r
rrr]rvr�rrrr�<module>s h*b