Hacked By AnonymousFox

Current Path : /opt/imunify360/venv/lib/python3.11/site-packages/docutils/parsers/rst/__pycache__/
Upload File :
Current File : //opt/imunify360/venv/lib/python3.11/site-packages/docutils/parsers/rst/__pycache__/tableparser.cpython-311.pyc

�

i��f�Q���dZdZddlZddlZddlmZddlmZGd�de��ZGd�d	��Z	Gd
�de	��Z
Gd�d
e	��Zd�ZdS)a�
This module defines table parser classes,which parse plaintext-graphic tables
and produce a well-formed data structure suitable for building a CALS table.

:Classes:
    - `GridTableParser`: Parse fully-formed tables represented with a grid.
    - `SimpleTableParser`: Parse simple tables, delimited by top & bottom
      borders.

:Exception class: `TableMarkupError`

:Function:
    `update_dict_of_lists()`: Merge two dictionaries containing list values.
�reStructuredText�N)�	DataError��strip_combining_charsc��eZdZdZd�ZdS)�TableMarkupErrorz�
    Raise if there is any problem with table markup.

    The keyword argument `offset` denotes the offset of the problem
    from the table's start line.
    c�`�|�dd��|_tj|g|�R�dS)N�offsetr)�popr
r�__init__)�self�args�kwargss   ��/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib/python3.11/site-packages/docutils/parsers/rst/tableparser.pyrzTableMarkupError.__init__&s6���j�j��1�-�-�����4�'�$�'�'�'�'�'�'�N)�__name__�
__module__�__qualname__�__doc__r�rrrrs-��������(�(�(�(�(rrc�*�eZdZdZdZ	dZ	d�Zd�ZdS)�TableParserzR
    Abstract superclass for the common parts of the syntax-specific parsers.
    N�c��|�|��|���|���|���S)an
        Analyze the text `block` and return a table data structure.

        Given a plaintext-graphic table in `block` (list of lines of text; no
        whitespace padding), parse the table, construct and return the data
        necessary to construct a CALS table or equivalent.

        Raise `TableMarkupError` if there is any problem with the markup.
        )�setup�find_head_body_sep�parse_table�structure_from_cells�r
�blocks  r�parsezTableParser.parse7sL��	
�
�
�5�������!�!�!��������(�(�*�*�*rc��tt|j����D]x}|j|}|j�|��rO|jr#t
d|jdz�d|dz�d�|����||_|�dd��|j|<�y|jdks |jt|j��dz
krt
d	|����d
S)z>Look for a head/body row separator line; store the line index.z/Multiple head/body row separators (table lines �z and z); only one allowed.�r
�=�-rzKThe head/body row separator may not be the first or last line of the table.N)�range�lenr �head_body_separator_pat�match�
head_body_sepr�replace)r
�i�lines   rrzTableParser.find_head_body_sepFs���s�4�:���'�'�
	;�
	;�A��:�a�=�D��+�1�1�$�7�7�
;��%�;�*�*� �-�a�/�/�/��1����6�>?�A�A�A�A�
*+�D�&�$(�L�L��c�$:�$:�D�J�q�M�����"�"�d�&8�S���_�_�?@�>A�'B�'B�"�$J�*+�-�-�-�
-�'B�'Br)rrrrr)�double_width_pad_charr!rrrrrr+sP��������#��D�"��=�
+�
+�
+�-�-�-�-�-rrc�n�eZdZdZejd��Zd�Zd�Zd�Z	d�Z
d�Zd�Zd	�Z
d
�Zd�Zd�Zd
S)�GridTableParserai	
    Parse a grid table using `parse()`.

    Here's an example of a grid table::

        +------------------------+------------+----------+----------+
        | Header row, column 1   | Header 2   | Header 3 | Header 4 |
        +========================+============+==========+==========+
        | body row 1, column 1   | column 2   | column 3 | column 4 |
        +------------------------+------------+----------+----------+
        | body row 2             | Cells may span columns.          |
        +------------------------+------------+---------------------+
        | body row 3             | Cells may  | - Table cells       |
        +------------------------+ span rows. | - contain           |
        | body row 4             |            | - body elements.    |
        +------------------------+------------+---------------------+

    Intersections use '+', row separators use '-' (except for one optional
    head/body row separator, which uses '='), and column separators use '|'.

    Passing the above table to the `parse()` method will result in the
    following data structure::

        ([24, 12, 10, 10],
         [[(0, 0, 1, ['Header row, column 1']),
           (0, 0, 1, ['Header 2']),
           (0, 0, 1, ['Header 3']),
           (0, 0, 1, ['Header 4'])]],
         [[(0, 0, 3, ['body row 1, column 1']),
           (0, 0, 3, ['column 2']),
           (0, 0, 3, ['column 3']),
           (0, 0, 3, ['column 4'])],
          [(0, 0, 5, ['body row 2']),
           (0, 2, 5, ['Cells may span columns.']),
           None,
           None],
          [(0, 0, 7, ['body row 3']),
           (1, 0, 7, ['Cells may', 'span rows.', '']),
           (1, 1, 7, ['- Table cells', '- contain', '- body elements.']),
           None],
          [(0, 0, 9, ['body row 4']), None, None, None]])

    The first item is a list containing column widths (colspecs). The second
    item is a list of head rows, and the third is a list of body rows. Each
    row contains a list of cells. Each cell is either None (for a cell unused
    because of another cell's span), or a tuple. A cell tuple contains four
    items: the number of extra rows used by the cell in a vertical span
    (morerows); the number of extra columns used by the cell in a horizontal
    span (morecols); the line offset of the first line of the cell contents;
    and the cell contents, a list of lines of text.
    z\+=[=+]+=\+ *$c�>�|dd�|_|j���t|��dz
|_t|d��dz
|_d|_dgt|d��z|_g|_ddgi|_ddgi|_	dS)Nr#r���)
r �
disconnectr(�bottom�rightr+�done�cells�rowseps�colsepsrs  rrzGridTableParser.setup�s����1�1�1�X��
��
�������%�j�j�1�n�����q��]�]�Q�&��
�!����D�3�u�Q�x�=�=�(��	���
��A�3�x����A�3�x����rc���dg}|�rE|�d��\}}||jks||jks||j|kr�C|�||��}|s�\|\}}}}t|j|��t|j|��|�||||��|j	�
|dz|dz||��}	|	���|	�|j
d��|j�|||||	f��|�||f||fg��|���|��E|���st'd���dS)a	
        Start with a queue of upper-left corners, containing the upper-left
        corner of the table itself. Trace out one rectangular cell, remember
        it, and add its upper-right and lower-left corners to the queue of
        potential upper-left corners of further cells. Process the queue in
        top-to-bottom order, keeping track of how much of each text column has
        been seen.

        We'll end up knowing all the row and column boundaries, cell positions
        and their dimensions.
        )rrrr#�z"Malformed table; parse incomplete.N)rr5r6r7�	scan_cell�update_dict_of_listsr9r:�	mark_doner �get_2D_blockr4r,r/r8�append�extend�sort�check_parse_completer)
r
�corners�top�left�resultr5r6r9r:�	cellblocks
          rrzGridTableParser.parse_table�s����(���	����A���I�C���t�{�"�"��4�:�%�%��$�)�D�/�)�)���^�^�C��.�.�F��
��.4�+�F�E�7�G� ���w�7�7�7� ���w�7�7�7��N�N�3��f�e�4�4�4��
�/�/��a�����06��?�?�I�� � �"�"�"����d�8�"�=�=�=��J���s�D�&�%��C�D�D�D��N�N�S�%�L�6�4�.�9�:�:�:��L�L�N�N�N�'�	�(�(�(�*�*�	I�"�#G�H�H�H�	I�	Irc�z�|dz
}|dz
}t||��D]}|j||ksJ�||j|<� dS)z@For keeping track of how much of each text column has been seen.r#N)r'r7)r
rFrGr5r6�before�after�cols        rr?zGridTableParser.mark_done�s[���q�����
����u�%�%�	#�	#�C��9�S�>�V�+�+�+�+�"�D�I�c�N�N�	#�	#rc�p�|jdz
}t|j��D]}|j||krdS�dS)z2Each text column should have been completely seen.r#FT)r5r'r6r7)r
�lastrMs   rrDz$GridTableParser.check_parse_complete�sH���{�Q������$�$�	�	�C��y��~��%�%��u�u�&��trc�`�|j||dksJ�|�||��S)z:Starting at the top-left corner, start tracing out a cell.�+)r �
scan_right)r
rFrGs   rr=zGridTableParser.scan_cell�s2���z�#��t�$��+�+�+�+����s�D�)�)�)rc��i}|j|}t|dz|jdz��D][}||dkr>|g||<|�|||��}|r|\}}}	t	||	��||||fcS�L||dkrdS�\dS)zr
        Look for the top-right corner of the cell, and make note of all column
        boundaries ('+').
        r#rQr&N)r r'r6�	scan_downr>)
r
rFrGr:r.r-rHr5r9�
newcolsepss
          rrRzGridTableParser.scan_right�s���
���z�#����t�a�x���a��0�0�		�		�A��A�w�#�~�~�!�U���
�����T�1�5�5���7�28�/�F�G�Z�(��*�=�=�=�!�1�g�w�6�6�6�6�7��a��C����t�t� ��trc�"�i}t|dz|jdz��D]p}|j||dkr=|g||<|�||||��}|r|\}}t	||��|||fcS�V|j||dkrdS�qdS)zj
        Look for the bottom-right corner of the cell, making note of all row
        boundaries.
        r#rQ�|N)r'r5r �	scan_leftr>)	r
rFrGr6r9r-rH�
newrowsepsr:s	         rrTzGridTableParser.scan_down�s���
���s�Q�w���a��0�0�		�		�A��z�!�}�U�#�s�*�*�#�W���
�����T�1�e�<�<���/�*0�'�J��(��*�=�=�=��g�w�.�.�.�.�/���A��u�%��,�,��t�t�-��trc���i}|j|}t|dz
|d��D]$}||dkr|g||<�||dkrdS�%||dkrdS|�||||��}|�|}	|	|fSdS)z�
        Noting column boundaries, look for the bottom-left corner of the cell.
        It must line up with the starting point.
        r#r3rQr&N)r r'�scan_up)
r
rFrGr5r6r:r.r-rHr9s
          rrXzGridTableParser.scan_left�s���
���z�&�!���u�q�y�$��+�+�	�	�A��A�w�#�~�~�$�X���
�
��a��C����t�t� ���:�����4����c�4���7�7�����G��G�#�#��trc��i}t|dz
|d��D]:}|j||dkr|g||<� |j||dkrdS�;|S)zT
        Noting row boundaries, see if we can return to the starting point.
        r#r3rQrWN)r'r )r
rFrGr5r6r9r-s       rr[zGridTableParser.scan_upsr�����v��z�3��+�+�	�	�A��z�!�}�T�"�c�)�)�"�V���
�
���A��t�$��+�+��t�t�,��rc����t|j�����}i}tt	|����D]
}||||<�t|j������i}tt	�����D]
}||�|<��fd�tdt	�����D��}d�tt	���dz
��D����fd�tt	|��dz
��D��}t	|��dz
t	���dz
z}|jD]y\}}	}
}}||}
||	}||
|�Jd|
dz�d|dz�d����||
|
z
dz
}|||z
dz
}||dz|dzzz}|||dz|f||
|<�z|d	ks
Jd
���|jr"||j}|d|�}||d�}ng}|}|||fS)zh
        From the data collected by `scan_cell()`, convert to the final data
        structure.
        c�>��g|]}�|�|dz
z
dz
��S)r#r)�.0r-r:s  �r�
<listcomp>z8GridTableParser.structure_from_cells.<locals>.<listcomp>(s?���5�5�5���Q�Z�'�!�a�%�.�0�1�4�5�5�5rr#c��g|]}d��S�Nr)r_r-s  rr`z8GridTableParser.structure_from_cells.<locals>.<listcomp>+s��8�8�8�1�$�8�8�8rc�$��g|]}�dd���
Srbr)r_r-�onerows  �rr`z8GridTableParser.structure_from_cells.<locals>.<listcomp>,s!���;�;�;�a��q�q�q�	�;�;�;rNz
Cell (row z	, column z) already used.rzUnused cells remaining.)�sortedr9�keysr'r(r:r8r+)r
r9�rowindexr-�colindex�colspecs�rows�	remainingrFrGr5r6r �rownum�colnum�morerows�morecols�numheadrows�headrows�bodyrowsr:rds                    @@rrz$GridTableParser.structure_from_cellssw����
���*�*�,�,�-�-�����s�7�|�|�$�$�	%�	%�A�#$�H�W�Q�Z� � ����*�*�,�,�-�-�����s�7�|�|�$�$�	%�	%�A�#$�H�W�Q�Z� � �5�5�5�5�"�1�c�'�l�l�3�3�5�5�5��9�8��c�'�l�l�Q�&6� 7� 7�8�8�8��;�;�;�;�5��W����)9�#:�#:�;�;�;����\�\�A�%�#�g�,�,��*:�;�	�/3�z�
	H�
	H�+�C��v�u�e��c�]�F��d�^�F���<��'�/�/�/��a�Z�Z�Z��!����-�0�/�/� ��'�&�0�1�4�H�����/�!�3�H��(�Q�,�8�a�<�8�8�I�$,�h��a���#G�D��L�� � ��A�~�~�~�8�~�~�~���	�"�4�#5�6�K��L�[�L�)�H��K�L�L�)�H�H��H��H���8�+�+rN)rrrr�re�compiler)rrr?rDr=rRrTrXr[rrrrr1r1Zs�������2�2�h)�b�j�):�;�;��	 �	 �	 �"I�"I�"I�H#�#�#����*�*�*�
���&���$���(
�
�
�',�',�',�',�',rr1c�~�eZdZdZejd��Zejd��Zd�Zd�Z	d�Z
d�Zdd	�Zd
�Z
d�ZdS)
�SimpleTableParseraQ
    Parse a simple table using `parse()`.

    Here's an example of a simple table::

        =====  =====
        col 1  col 2
        =====  =====
        1      Second column of row 1.
        2      Second column of row 2.
               Second line of paragraph.
        3      - Second column of row 3.

               - Second item in bullet
                 list (row 3, column 2).
        4 is a span
        ------------
        5
        =====  =====

    Top and bottom borders use '=', column span underlines use '-', column
    separation is indicated with spaces.

    Passing the above table to the `parse()` method will result in the
    following data structure, whose interpretation is the same as for
    `GridTableParser`::

        ([5, 25],
         [[(0, 0, 1, ['col 1']),
           (0, 0, 1, ['col 2'])]],
         [[(0, 0, 3, ['1']),
           (0, 0, 3, ['Second column of row 1.'])],
          [(0, 0, 4, ['2']),
           (0, 0, 4, ['Second column of row 2.',
                      'Second line of paragraph.'])],
          [(0, 0, 6, ['3']),
           (0, 0, 6, ['- Second column of row 3.',
                      '',
                      '- Second item in bullet',
                      '  list (row 3, column 2).'])],
          [(0, 1, 10, ['4 is a span'])],
          [(0, 0, 12, ['5']),
           (0, 0, 12, [''])]])
    z=[ =]*$z-[ -]*$c��|dd�|_|j���|jd�dd��|jd<|jd�dd��|jd<d|_g|_d|_g|_dgt|d��z|_ddgi|_	ddgi|_
dS)Nrr%r&r3)r r4r,r+�columns�
border_end�tabler(r7r9r:rs  rrzSimpleTableParser.setupws����1�1�1�X��
��
�������
�1�
�-�-�c�3�7�7��
�1�
���B��/�/��S�9�9��
�2��!�����������
��D�3�u�Q�x�=�=�(��	��A�3�x����A�3�x����rc��|�|jdd��|_|jdd|_|jd\}}d}d}d}|t	|j��kr�|j|}|j�|��r@|�|j||�||���|f��|dz}d}nS|||��	��r0|r)||kr#|�|j||�|��|}d}n|s|dz}|dz
}|t	|j��k��dSdS)z�
        First determine the column boundaries from the top border, then
        process rows.  Each row may consist of multiple lines; accumulate
        lines until a row is complete.  Call `self.parse_row` to finish the
        job.
        rr3r#N)
�
parse_columnsr rxryr(�span_patr*�	parse_row�rstrip�strip)r
�
firststart�firstendr
�start�
text_foundr.s       rrzSimpleTableParser.parse_table�sd���)�)�$�*�Q�-��;�;����,�r�*�1�-���#�|�A���
�H������
��s�4�:���&�&��:�f�%�D��}�"�"�4�(�(�

#����t�z�%��,�7�� $���
�
�v�6�8�8�8���
��!�
�
��j��)�*�0�0�2�2�
#��D�&�E�/�/��N�N�4�:�e�F�l�#;�U�C�C�C����
�
��
#���
���a�K�F�!�s�4�:���&�&�&�&�&�&rc��g}d}	|�d|��}|�d|��}|dkrn-|dkrt|��}|�||f���`|jrR|dd|jkrtd|dzz|����|dd|jddf|d<|S)	zU
        Given a column span underline, return a list of (begin, end) pairs.
        rTr&� r3r#z(Column span incomplete in table line %s.r$)�findr(rArxryr)r
r.r
�cols�end�begins      rr|zSimpleTableParser.parse_columns�s�������	&��I�I�c�3�'�'�E��)�)�C��'�'�C��q�y�y���Q�w�w��$�i�i���K�K����%�%�%�	&��<�	:��B�x��{�d�o�-�-�&�(2�5;�A�X�(?�.4�6�6�6�6��R����T�\�"�%5�a�%8�9�D��H��rc�b�d}g}|D]�\}}d}	||j|dksJ�||j|dkr!|dz
}|dz
}||j|dk�!n/#ttf$rtd|dzz|dz����wxYw|�d||gg��|dz
}��|S)Nrr#z/Column span alignment problem in table line %s.�r$)rx�AssertionError�
IndexErrorrrA)r
�colspecr
r-r8r�r�ros        r�init_rowzSimpleTableParser.init_row�s��
����!�	�	�J�E�3��H�
8����Q��� 2�2�2�2�2��T�\�!�_�Q�/�/�/���F�A���M�H��T�\�!�_�Q�/�/�/���#�J�/�
8�
8�
8�&�(;�>D�Q�h�(H�.4�Q�h�8�8�8�8�
8����
�L�L�!�X�v�r�2�3�3�3�
��F�A�A��s�AA!�!,B
Nc���|s|sdS|r|j|�}n|jdd�}|�|||��|�||��}t	t|����D]l}||\}}|�d|t|��|��}|���|�|j	d��|||d<�m|j
�|��dS)af
        Given the text `lines` of a row, parse it and append to `self.table`.

        The row is parsed according to the current column spec (either
        `spanline` if provided or `self.columns`).  For each column, extract
        text from each line, and check for text in column margins.  Finally,
        adjust for insignificant whitespace.
        Nrr<�)r|rx�
check_columnsr�r'r(r@r4r,r/rzrA)	r
�linesr��spanlinerx�rowr-r�rIs	         rr~zSimpleTableParser.parse_row�s
���	��	��F��	&�(�d�(�(�3�G�G��l�1�1�1�o�G����5�%��1�1�1��m�m�G�U�+�+���s�7�|�|�$�$�	"�	"�A� ���J�E�3��*�*�1�e�S��Z�Z��E�E�I�� � �"�"�"����d�8�"�=�=�=�!�C��F�1�I�I��
���#�����rc���|�tjdf��t|��dz
}d�|D��}t	t|��dz
��D]�}||\}}||dzd}d}	|D]�}
||kr�|
|d����rf|
|d����}|t|��z}|jd\}
}|t||��f||<||kr|
|f|jd<n9|
||����rtd||	zdzz||	z����|	dz
}	�Ɍ�|�
��dS)	z�
        Check for text in column margins and text overflow in the last column.
        Raise TableMarkupError if anything but whitespace is in column margins.
        Adjust the end value for the last column if there is text overflow.
        Nr�c�,�g|]}t|����Srr)r_r.s  rr`z3SimpleTableParser.check_columns.<locals>.<listcomp>�s!��?�?�?��&�t�,�,�?�?�?rr#rr3z'Text in column margin in table line %s.r$)rA�sys�maxsizer(r'r�rrx�maxrr)r
r��
first_linerx�lastcolr-r�r��	nextstartr
r.�text�new_end�
main_start�main_ends               rr�zSimpleTableParser.check_columns�s���	�����T�*�+�+�+��g�,�,��"��?�?��?�?�?���s�7�|�|�a�'�(�(�	�	�A� ���J�E�3���!���Q��I��F��
�
����<�<�D����J�$4�$4�$6�$6�<�����<�.�.�0�0�D�#�c�$�i�i�/�G�+/�<��+;�(�J��"'��X�w�)?�)?�!@�G�A�J���)�)�,6��+@���R�(���#�i�-�(�.�.�0�0�E�*�,6�9C�F�9J�1�9L�,N�2<�V�2C�E�E�E�E��!����
�	���
�
�
�
�
rc��d�|jD��}d}|jrJtt|j����D](}|j|dd|jkr|}n�)||jd|�|j|d�fS)Nc��g|]
\}}||z
��Srr)r_r�r�s   rr`z:SimpleTableParser.structure_from_cells.<locals>.<listcomp>	s ��?�?�?�J�E�3�C�%�K�?�?�?rrr�)rxr+r'r(rz)r
ri�first_body_rowr-s    rrz&SimpleTableParser.structure_from_cellss���?�?�$�,�?�?�?������	��3�t�z�?�?�+�+�
�
���:�a�=��#�A�&��);�;�;�%&�N��E�<��$�*�_�n�_�5��
�>�?�?�+�-�	-rrb)rrrrrsrtr)r}rrr|r�r~r�rrrrrvrvEs�������+�+�Z)�b�j��3�3���r�z�)�$�$�H� � � ����@���.���$����4���@	-�	-�	-�	-�	-rrvc��|���D].\}}|�|g���|���/dS)z�
    Extend the list values of `master` with those from `newdata`.

    Both parameters must be dictionaries containing list values.
    N)�items�
setdefaultrB)�master�newdata�key�valuess    rr>r>sP���}�}���2�2���V����#�r�"�"�)�)�&�1�1�1�1�2�2r)
r�
__docformat__rsr��docutilsr�docutils.utilsrrrr1rvr>rrr�<module>r�s ��

�
�#�
�
�	�	�	�
�
�
�
�������0�0�0�0�0�0�(�(�(�(�(�y�(�(�(�,-�,-�,-�,-�,-�,-�,-�,-�^h,�h,�h,�h,�h,�k�h,�h,�h,�VL-�L-�L-�L-�L-��L-�L-�L-�^2�2�2�2�2r

Hacked By AnonymousFox1.0, Coded By AnonymousFox