HEX
Server: LiteSpeed
System: Linux s787.bom1.mysecurecloudhost.com 4.18.0-477.13.1.lve.el8.x86_64 #1 SMP Thu Jun 1 16:40:47 EDT 2023 x86_64
User: mobilech (5348)
PHP: 8.1.34
Disabled: NONE
Upload Files
File: //lib/python3.6/site-packages/docutils/parsers/rst/directives/__pycache__/tables.cpython-36.pyc
3

v2�eXW�@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.
ZreStructuredText�N)�io�nodes�statemachine�utils)�
SafeString)�SystemMessagePropagation)�	Directive)�
directivescCstj|d�S)N�left�center�right)r
rr)r	Zchoice)Zargument�r
�/usr/lib/python3.6/tables.py�alignsrc@sleZdZdZdZdZejeje	ej
dej�d�ZdZ
dd�Zd	d
�Zdd�Zed
d��Zdd�Zdd�ZdS)�Tablez#
    Generic table base class.
    �T�auto�grid)�class�namer�widthscCs^|jrN|jd}|jj||j�\}}tj|df|��}|jj|j�\|_|_	nd}g}||fS)Nr�)
Z	arguments�stateZinline_text�linenor�title�
state_machineZget_source_and_line�source�line)�selfZ
title_textZ
text_nodes�messagesrr
r
r�
make_title*s
zTable.make_titlecCsX|jj|jd�}g}d}d|jkrP|j|jdjd�|j�|�\}}|j|�||fS)Nrr�header�
)r�
get_sourcer�options�parse_csv_data_into_rows�split�
HeaderDialect�extend)rr�
table_head�max_header_cols�rowsr
r
r�process_header_option7s


zTable.process_header_optioncCsHt|�|krF|jjjd|t|�|jftj|j|j�|jd�}t	|��t|�|ko\dknr�|jjjdt|�|jftj|j|j�|jd�}t	|��x�|D]�}t|�|kr�|jjjd|t|�|jftj|j|j�|jd�}t	|��t|�|k�odknr�|jjjdt|�|jftj|j|j�|jd�}t	|��q�WdS)NzP%s header row(s) specified but only %s row(s) of data supplied ("%s" directive).)rrzeInsufficient 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)rr+�header_rows�stub_columnsr/�rowr
r
r�check_table_dimensionsBs2
zTable.check_table_dimensionscCs|jjdd�S)Nrr)r$�get)rr
r
rraszTable.widthscCs�t|j�tkrXt|j�|krP|jjjd|j|ftj	|j
|j
�|jd�}t|��|j}n>|rld|g|}n*|jjjdtj	|j
|j
�|jd�}t|��|S)Nz="%s" widths do not match the number of columns in table (%s).)r�dz#No table data detected in CSV file.)
�typer�listr-rr.r/rrr0r1rr)r�max_colsr/�
col_widthsr
r
r�get_column_widthseszTable.get_column_widthscCsLxF|D]>}x8|D]0}t|�|kr|jdddgfg|t|��qWqWdS)Nr)r-r()r�columns�parts�partr4r
r
r�"extend_short_rows_with_empty_cellsws

z(Table.extend_short_rows_with_empty_cellsN)rr)�__name__�
__module__�__qualname__�__doc__Zoptional_argumentsZfinal_argument_whitespacer	�class_option�	unchangedr�value_or�positive_int_list�option_specZhas_contentr r,r5�propertyrr<r@r
r
r
rrs
rc@seZdZdd�ZdS)�RSTTablecCs�|js4|jjjd|jtj|j|j�|jd�}|gS|j	�\}}tj
�}|jj|j|j
|�t|�dkszt|dtj�r�|jjjd|jtj|j|j�|jd�}|gS|d}|d|jjdg�7<d|jkr�|jjd�|d<|d}t|j�tk�r0d	d
�|jD�}x"t||j�D]\}	}
|
|	d<�qW|jdk�rP|dd
g7<n|j�rj|ddg7<|j|�|�r�|jd|�|g|S)Nz:Content block expected for the "%s" directive; none found.)rrrzOError parsing content block for the "%s" directive: exactly one table expected.�classesrrcSsg|]}|jdkr|�qS)�colspec)Ztagname)�.0Zchildr
r
r�
<listcomp>�sz RSTTable.run.<locals>.<listcomp>�colwidthrzcolwidths-autozcolwidths-given)�contentrr.�warningrrr0r1rr �Elementr�nested_parse�content_offsetr-�
isinstance�tabler/r$r6r8rr9�children�zip�add_name�insert)rrRrr�noder/�
table_node�tgroupZcolspecsrM�	col_widthr
r
r�run�s@



zRSTTable.runN)rArBrCr`r
r
r
rrK~srKc@s�eZdZejejejejdej�ejej	ej
ejejeej
ejejejd�ZGdd�dej�ZGdd�dej�Zdd�Zd	d
�Zdd�Zejdkr�dd�Zdd�Zndd�Zdd�Zee�Zee�Zdd�ZdS)�CSVTabler)zheader-rowszstub-columnsr!r�file�url�encodingrrr�delim�	keepspace�quote�escapec@s6eZdZdZdZdZdZdZdZdZ	e
jZdd�Z
dS)	zCSVTable.DocutilsDialectz&CSV dialect for `csv_table` directive.�,�"Tr"cCsld|krtj|d�|_d|kr&d|_d|kr>tj|d�|_d|kr\d|_tj|d�|_tjj	|�dS)NrerfFrgrh)
ra�encode_for_csv�	delimiter�skipinitialspace�	quotechar�doublequote�
escapechar�csv�Dialect�__init__)rr$r
r
rrs�sz!CSVTable.DocutilsDialect.__init__N)rArBrCrDrlrnrorm�strict�lineterminatorrq�
QUOTE_MINIMAL�quotingrsr
r
r
r�DocutilsDialect�srxc@s2eZdZdZdZdZdZdZdZdZ	dZ
ejZ
dS)	zCSVTable.HeaderDialectz0CSV dialect to use for the "header" option data.rirj�\FTr"N)rArBrCrDrlrnrprormrtrurqrvrwr
r
r
rr'�sr'cCsdS)Nr
)rr
r
r�check_requirements�szCSVTable.check_requirementscCs(�y|jjjjrTd|jks&d|jkrT|jjjd|jt	j
|j|j�|jd�}|gS|j
�|j�\}}|j�\}}|j�\}}|j||j|j�|�\}}	t|	|�}	|jjdd�}
|jjdd�}|j||
|�|j|d|
��||
d�}|j|	�}
|j|	||f�Wn�tk
�r2}z|jdgSd}~Xnxtjk
�r�}zXt|�}tjdk�rld	|k�rl|d
7}|jjj d|j|ft	j
|j|j�|jd�}|gSd}~XnX|
||f}|jj!||j"||j#d�}|d
|jjdg�7<d|jk�r|jjd�|d<|j$|�|�r|j%d|�|g|S)Nrbrcz9File and URL access deactivated; ignoring "%s" directive.)rzheader-rowsrzstub-columns�z1-character stringz1
with Python 2.x this must be an ASCII character.z)Error with CSV data in "%s" directive:
%s)rrLrr)r{)&r�document�settingsZfile_insertion_enabledr$rr.rRrrr0r1rrzr �get_csv_datar,r%rx�maxr6r5r(r<r@r�argsrq�Error�str�sys�version_infor/Zbuild_tablerUrrZr[)rrRrr�csv_datarr)r*r+r:r2r3Z
table_bodyr;�detail�messager/rWr]r
r
rr`�sZ






zCSVTable.runcCs�|jjd|jjjj�}|jjjj}|jr�d|jks<d|jkrl|jj	j
d|jtj
|j|j�|jd�}t|��|jjd�}|j}�n(d|jk�r�d|jkr�|jj	j
d|jtj
|j|j�|jd�}t|��tjjtjj|jjj��}tjjtjj||jd��}tjd|�}y2|jjjjj|�tj|||d	�}|j�j �}Wn\t!k
�r�}z>|jj	j"d
|jt#|�ftj
|j|j�|jd�}t|��WYdd}~XnX�nd|jk�rzddl$}	ddl%}	ddl&}	|jd}y|	j'j(|�j�}
Wnp|	j
j)t!t*t+fk
�rP}zF|jj	j"d|j|jdt#|�ftj
|j|j�|jd�}t|��WYdd}~XnXtj,|
|||jjjjd�}|j�j �}n0|jj	j-d
|jtj
|j|j�|jd�}t|��||fS)zr
        Get CSV data from the directive content, from an external
        file, or from a URL reference.
        rdrbrczF"%s" directive may not both specify an external file and have content.)rrzXThe "file" and "url" options may not be simultaneously specified for the "%s" directive.N)�source_pathrd�
error_handlerz&Problems with "%s" directive path:
%s.z*Problems with "%s" directive URL "%s":
%s.)rr�rdr�z3The "%s" directive requires content; none supplied.).r$r6rr|r}Zinput_encodingZinput_encoding_error_handlerrQrr.r/rrr0r1rrr�os�path�dirname�abspathZcurrent_source�normpath�joinrZ
relative_pathZrecord_dependencies�addrZ	FileInput�read�
splitlines�IOError�severerZurllib.requestZurllib.errorZurllib.parseZrequestZurlopenZURLError�OSError�
ValueErrorZStringInputrR)rrdr�r/rr�Z
source_dirZcsv_filer�ZurllibZcsv_textr
r
rr~sx







zCSVTable.get_csv_datar{cCs
|jd�S)Nzutf-8)�decode)�sr
r
r�decode_from_csvaszCSVTable.decode_from_csvcCs
|jd�S)Nzutf-8)�encode)r�r
r
rrkcszCSVTable.encode_for_csvcCs|S)Nr
)r�r
r
rr�fscCs|S)Nr
)r�r
r
rrkhsc	s�tj�fdd�|D�|d�}g}d}xd|D]\}g}x:|D]2}	�j|	�}
dddtj|
j�|d�f}|j|�q8W|j|�t|t|��}q*W||fS)Ncsg|]}�j|d��qS)r")rk)rNr)rr
rrOosz5CSVTable.parse_csv_data_into_rows.<locals>.<listcomp>)�dialectr)r)	rq�readerr�rZ
StringListr��appendrr-)rr�r�rZ
csv_readerr+r:r4Zrow_data�cellZ	cell_textZ	cell_datar
)rrr%ms




z!CSVTable.parse_csv_data_into_rowsN)r)r{)rArBrCr	�nonnegative_intrFrGrHr�ZurirdrErZ$single_char_or_whitespace_or_unicode�flagZsingle_char_or_unicoderIrqrrrxr'rzr`r~r�r�r�rk�staticmethodr%r
r
r
rra�s8

/J

rac@sLeZdZdZejejejdej�ejej	e
d�Zdd�Zdd�Z
dd	�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
    r)zheader-rowszstub-columnsrrrrcCs@|js4|jjjd|jtj|j|j�|jd�}|gS|j	�\}}tj
�}|jj|j|j
|�yN|j|�\}}dd�|dD�}|jjdd�}|jjdd�}	|j|||	�Wn(tk
r�}
z|
jdgSd}
~
XnX|j||||	�}d|jk�r|jjd�|d<|d	|jjd
g�7<|j|�|�r6|jd|�|g|S)Nz.The "%s" directive is empty; content required.)rcSsg|]}dd�|dD��qS)cSsg|]
}|j�qSr
)rX)rN�itemr
r
rrO�sz,ListTable.run.<locals>.<listcomp>.<listcomp>rr
)rNZrow_listr
r
rrO�sz!ListTable.run.<locals>.<listcomp>rzheader-rowszstub-columnsrrLr)rQrr.r/rrr0r1rr rSrrTrU�check_list_contentr$r6r5rr��build_table_from_listrZr[)rr/rrr\�num_colsr;�
table_datar2r3r�r]r
r
rr`�s6

z
ListTable.runcCsHt|�dkst|dtj�rN|jjjd|jtj|j	|j	�|j
d�}t|��|d}x�tt|��D]�}||}t|�dks�t|dtj�r�|jjjd|j|dftj|j	|j	�|j
d�}t|��qd|�r&t|d�|k�r2|jjjd|j|dt|d�|ftj|j	|j	�|j
d�}t|��qdt|d�}qdW|j
|�}||fS)NrrzUError parsing content block for the "%s" directive: exactly one bullet list expected.)rz�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).)r-rVrZbullet_listrr.r/rr0r1rr�ranger<)rr\r/Z	list_nodeZ
item_indexr�r�r;r
r
rr��s6




zListTable.check_list_contentcCs4tj�}|jdkr&|ddg7<n|jr>|ddg7<tjt|�d�}||7}xD|D]<}tj�}|dk	rz||jd<|r�d|jd<|d8}||7}q\Wg}	xD|D]<}
tj�}x$|
D]}tj�}
|
|7}
||
7}q�W|	j	|�q�W|�rtj
�}|j|	d|��||7}tj�}|j|	|d��||7}|S)	NrrLzcolwidths-autozcolwidths-given)ZcolsrPrZstub)
rrWrr^r-rMZ
attributesr4�entryr��theadr(�tbody)rr�r;r2r3rWr^r_rMr+r4Zrow_noder�r�r�r�r
r
rr��s>





zListTable.build_table_from_listN)r)rArBrCrDr	r�rGrHrErFrrIr`r�r�r
r
r
rr��s'r�)rDZ
__docformat__r�Zos.pathr�rqZdocutilsrrrrZdocutils.utils.error_reportingrZdocutils.utilsrZdocutils.parsers.rstrr	rrrKrar�r
r
r
r�<module>sc)[