Hacked By AnonymousFox

Current Path : /opt/cloudlinux/venv/lib/python3.11/site-packages/prettytable/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib/python3.11/site-packages/prettytable/__pycache__/prettytable.cpython-311.pyc

�

�܋f�`��6�ddlmZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZddlm
Z
ddlmZddlZdZdZdZdZd	Zd
ZdZdZd
ZdZdZdZdZejd��Zd�Z Gd�d��Z!d�Z"d d!d�Z#d�Z$d�Z%Gd�de
��Z&d�Z'd�Z(dS)"�)�annotationsN)�escape)�
HTMLParser)�Any����
���
�����base_align_valuez\033\[[0-9;]*m|\033\(Bc��|�d��}t|��}td�|D����}||fS)N�
c3�4K�|]}t|��V��dS�N��_str_block_width��.0�lines  �N/opt/cloudlinux/venv/lib64/python3.11/site-packages/prettytable/prettytable.py�	<genexpr>z_get_size.<locals>.<genexpr>Is+����9�9�4� ��&�&�9�9�9�9�9�9�)�split�len�max)�text�lines�height�widths    r�	_get_sizer&FsD���J�J�t���E�
��Z�Z�F��9�9�5�9�9�9�9�9�E��&�=�rc�J�eZdZd�d�d�Zd�Zd�Zd�Zd�Zd	�Zd
�Z	d�Z
d�Zd
�Zd�Z
d�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zed�d���Zed�d���Zed�d!���Zejd"���Zed#���Z e jd$���Z ed%���Z!e!jd&���Z!ed'���Z"e"jd(���Z"ed)���Z#e#jd*���Z#ed+���Z$e$jd,���Z$ed-���Z%e%jd.���Z%ed/���Z&e&jd0���Z&ed1���Z'e'jd2���Z'ed3���Z(e(jd4���Z(ed5���Z)e)jd6���Z)ed7���Z*e*jd8���Z*ed9���Z+e+jd:���Z+ed;���Z,e,jd<���Z,ed=���Z-e-jd>���Z-ed?���Z.e.jd@���Z.edA���Z/e/jdB���Z/edC���Z0e0jdD���Z0edE���Z1e1jdF���Z1edG���Z2e2jdH���Z2edI���Z3e3jdJ���Z3edK���Z4e4jdL���Z4edM���Z5e5jdN���Z5edO���Z6e6jdP���Z6edQ���Z7e7jdR���Z7edS���Z8e8jdT���Z8edU���Z9e9jdV���Z9edW���Z:e:jdX���Z:edY���Z;e;jdZ���Z;ed[���Z<e<jd\���Z<ed]���Z=e=jd^���Z=ed_���Z>e>jd`���Z>eda���Z?e?jdb���Z?edc���Z@e@jdd���Z@ede���ZAeAjdf���ZAedg���ZBeBjdh���ZBedi���ZCeCjdj���ZCedk���ZDeDjdl���ZDedm���ZEeEjdn���ZEedo���ZFeFjdp���ZFedq���ZGeGjdr���ZGeds���ZHeHjdt���ZHedu���ZIeIjdv���ZIedw���ZJeJjdx���ZJdy�ZKd�dz�ZLd{�ZMd|�ZNd}�ZOd~�ZPd�ZQd��ZRd��ZSd��ZTd�d��ZUd�d��d�d��ZVd�d��ZW	d�d�d��ZXd�d�d��ZYd�d��ZZd�d��Z[d�d��Z\d��Z]d�d�d��Z^d��Z_d��Z`d��Zad��Zbd��Zcd��Zdd��Zed��Zfd�d��Zgd�d��Zhd��Zid��Zjd��Zkd�d�d��Zld�d��Zmd�d��Znd�d��Zod��Zpd��Zqd�d��Zrd��Zsd��ZtdS)��PrettyTableN�return�Nonec�B�|�dd��|_g|_g|_g|_i|_i|_i|_i|_i|_	i|_
i|_|r||_ng|_
gd�|_|jD](}||vr|�|||���#d||<�)|dpd|_|dpd|_|dpd|_|d	pd|_i|_|d
dvr|d
|_nd|_|d
pd|_|ddvr|d|_nd|_|ddvr|d|_nd|_|dpt2|_|dpt6|_|dpd|_|ddvr|d|_nd|_|dpd�|_|dpi|_|dpi|_|dpi|_|dpi|_|dpi|_	|dpi|_
|dpi|_|dpi|_ |dpd|_!|d pd|_"|d!�d"|_#n
|d!|_#|d#pd|_$|d$pd|_%|d%pd&|_&|d'pd(|_'|d)|_(|d*pd+|_)|d,|_*|d-|_+|d.|_,|d/|_-|d0|_.|d1|_/|d2|_0|d3|_1|d4dvr|d4|_2nd|_2|d5dvr|d5|_3nd|_3|d6pd|_4|d7pd|_5|d8pi|_6dS)9a�Return a new PrettyTable instance

        Arguments:

        encoding - Unicode encoding scheme used to decode any encoded input
        title - optional table title
        field_names - list or tuple of field names
        fields - list or tuple of field names to include in displays
        start - index of first data row to include in output
        end - index of last data row to include in output PLUS ONE (list slice style)
        header - print a header showing field names (True or False)
        header_style - stylisation to apply to field names in header
            ("cap", "title", "upper", "lower" or None)
        border - print a border around the table (True or False)
        preserve_internal_border - print a border inside the table even if
            border is disabled (True or False)
        hrules - controls printing of horizontal rules after rows.
            Allowed values: FRAME, HEADER, ALL, NONE
        vrules - controls printing of vertical rules between columns.
            Allowed values: FRAME, ALL, NONE
        int_format - controls formatting of integer data
        float_format - controls formatting of floating point data
        custom_format - controls formatting of any column using callable
        min_table_width - minimum desired table width, in characters
        max_table_width - maximum desired table width, in characters
        min_width - minimum desired field width, in characters
        max_width - maximum desired field width, in characters
        padding_width - number of spaces on either side of column data
            (only used if left and right paddings are None)
        left_padding_width - number of spaces on left hand side of column data
        right_padding_width - number of spaces on right hand side of column data
        vertical_char - single character string used to draw vertical lines
        horizontal_char - single character string used to draw horizontal lines
        horizontal_align_char - single character string used to indicate alignment
        junction_char - single character string used to draw line junctions
        top_junction_char - single character string used to draw top line junctions
        bottom_junction_char -
            single character string used to draw bottom line junctions
        right_junction_char - single character string used to draw right line junctions
        left_junction_char - single character string used to draw left line junctions
        top_right_junction_char -
            single character string used to draw top-right line junctions
        top_left_junction_char -
            single character string used to draw top-left line junctions
        bottom_right_junction_char -
            single character string used to draw bottom-right line junctions
        bottom_left_junction_char -
            single character string used to draw bottom-left line junctions
        sortby - name of field to sort rows by
        sort_key - sorting key function, applied to data points before sorting
        align - default align for each column (None, "l", "c" or "r")
        valign - default valign for each row (None, "t", "m" or "b")
        reversesort - True or False to sort in descending or ascending order
        oldsortslice - Slice rows before sorting in the "old style" �encodingzUTF-8),�title�start�end�fields�header�border�preserve_internal_border�sortby�reversesort�sort_key�
attributes�format�hrules�vrules�
int_format�float_format�
custom_format�min_table_width�max_table_width�
padding_width�left_padding_width�right_padding_width�
vertical_char�horizontal_char�horizontal_align_char�
junction_char�header_style�valign�xhtml�print_empty�oldsortslice�top_junction_char�bottom_junction_char�right_junction_char�left_junction_char�top_right_junction_char�top_left_junction_char�bottom_right_junction_char�bottom_left_junction_char�alignrH�	max_width�	min_width�none_formatNr-r.rr/r0r1�TFTrGr2r3Fr9r:r4r5r6c��|Sr�)�xs r�<lambda>z&PrettyTable.__init__.<locals>.<lambda>�s��!�rrTrHrUrVr;r<r=rWr>r?r@rrArBrC�|rD�-rErF�+rLrMrNrOrPrQrRrSrJrKr8rIr7)7�getr,�_field_names�_rows�	_dividersrTrHrUrVr;r<r=�field_names�_widths�_options�_validate_option�_title�_start�_end�_fields�_none_format�_header�
_header_style�_border�_preserve_internal_border�FRAME�_hrules�ALL�_vrules�_sortby�_reversesort�	_sort_keyrW�_min_table_width�_max_table_width�_padding_width�_left_padding_width�_right_padding_width�_vertical_char�_horizontal_char�_horizontal_align_char�_junction_char�_top_junction_char�_bottom_junction_char�_right_junction_char�_left_junction_char�_top_right_junction_char�_top_left_junction_char�_bottom_right_junction_char�_bottom_left_junction_char�_print_empty�
_oldsortslice�_format�_xhtml�_attributes)�selfrd�kwargs�options    r�__init__zPrettyTable.__init__NsO��p�
�
�:�w�7�7��
�(*���!#��
�%'�����
��������������������	)�*�D���&(�D�L�-
�-
�-
��
�\�m�	&�	&�F������%�%�f�f�V�n�=�=�=�=�!%��v����W�o�-�����W�o�*�����5�M�)�T��	��h�'�/�4���.0����(��}�,�,�!�(�+�D�L�L��D�L�#�N�3�;�t����(��}�,�,�!�(�+�D�L�L��D�L��,�-��>�>�-3�4N�-O�D�*�*�-2�D�*��h�'�0�5����h�'�.�3����h�'�/�4����-� �M�1�1� &�}� 5�D��� %�D���
�+�<������G�_�*���
��X�&�,�"�����,�2������,�2���� ��.�4�"���"�>�2�8�b���#�O�4�:����!�-�0�6�B��� &�'8� 9� A�T��� &�'8� 9� A�T����/�"�*�"#�D���"(��"9�D��#)�*>�#?�#G�4�� �$*�+@�$A�$I�T��!�$�_�5�<���� &�'8� 9� @�S���&,�-D�&E��#�$�_�5�<����"(�)<�"=���%+�,B�%C��"�$*�+@�$A��!�#)�*>�#?�� �(.�/H�(I��%�'-�.F�'G��$�+1�2N�+O��(�*0�1L�*M��'��-� �M�1�1� &�}� 5�D��� $�D���.�!�]�2�2�!'��!7�D���!&�D���h�'�0�5����W�o�.����!�,�/�5�2����rc��|t|��z
}|dkr||dzzS|dkr|dz|zS|dzr@t|��dzr|dzdz|z|dzdzdzzS|dzdzdz|z|dzdzzS|dzdz|z|dzdzzS)N�l� �rrrr)r�r"r%rT�excesss     r�_justifyzPrettyTable._justifys����)�$�/�/�/���C�<�<��&�3�,�&�&�
�c�\�\��C�<�$�&�&���z�
H�$�D�)�)�A�-�P�"�a�K�3�.��5��1��q��C�8O�O�O�#�a�K�!�O�s�2�T�9�V�q�[�C�<O�O�O�
�!��s�*�T�1�V�q�[�C�4G�G�Grc���|dkrt|j��S|dkr>|jrt|j��S|jrt|jd��SdSt|���)N�rowcount�colcountr)r rbra�AttributeError)r��names  r�__getattr__zPrettyTable.__getattr__,ss���:����t�z�?�?�"�
�Z�
�
�� �
��4�,�-�-�-���
��4�:�a�=�)�)�)��q� ��&�&�&rc
���t��}|j|_|jD]'}t|d|zt	|d|z�����(t|dt	|d����t|t��r&|j|D]}|�|���nIt|t��r!|�|j|��ntd|�d����|S)N�_�_alignzIndex z( is invalid, must be an integer or slice)r(rdrf�setattr�getattr�
isinstance�slicerb�add_row�int�
IndexError)r��index�new�attr�rows     r�__getitem__zPrettyTable.__getitem__9s����m�m���*����M�	@�	@�D��C��t��W�T�3��:�%>�%>�?�?�?�?���X�w�t�X�6�6�7�7�7��e�U�#�#�	W��z�%�(�
!�
!�����C� � � � �
!�
��s�
#�
#�	W��K�K��
�5�)�*�*�*�*��U�e�U�U�U�V�V�V��
rc�*�|���Sr��
get_string�r�s r�__str__zPrettyTable.__str__H������ � � rc�*�|���Srr�r�s r�__repr__zPrettyTable.__repr__Kr�rc�*�|���S)zs
        Returns get_html_string value by default
        as the repr call in Jupyter notebook environment
        )�get_html_stringr�s r�_repr_html_zPrettyTable._repr_html_Ns��
�#�#�%�%�%rc��|dkr|�|��dS|dkr|�|��dS|dvr|�||��dS|dkr|�||��dS|dkr|�||��dS|dkr|�||��dS|dkr|�||��dS|dkr|�||��dS|d	vr|�||��dS|d
kr|�	|��dS|dkr|�
||��dS|dkr|�||��dS|d
kr7|���D] \}}|�|�d|��|���!dS|dvr|�
||��dS|dkr|�||��dSdS)NrdrW)
r.r/rUrVr>r?r@rArBr8r4r6r9r:r0)r1r2r3r5rIrJrKrGr;r<r=�.)rCrDrErFrLrMrNrOrPrQrRrSr7)�_validate_field_names�_validate_none_format�_validate_nonnegative_int�_validate_field_name�_validate_function�_validate_hrules�_validate_vrules�_validate_all_field_names�_validate_true_or_false�_validate_header_style�_validate_int_format�_validate_float_format�items�_validate_single_char�_validate_attributes)r�r��val�k�	formatters     rrgzPrettyTable._validate_optionbs����]�"�"��&�&�s�+�+�+�+�+�
�}�
$�
$��&�&�s�+�+�+�+�+�
�
�
�
�
�*�*�6�3�7�7�7�7�7�
�x�
�
��%�%�f�c�2�2�2�2�2�
�z�
!�
!��#�#�F�C�0�0�0�0�0�
�x�
�
��!�!�&�#�.�.�.�.�.�
�x�
�
��!�!�&�#�.�.�.�.�.�
�x�
�
��*�*�6�3�7�7�7�7�7�
�
�
�
�
�(�(���5�5�5�5�5�
�~�
%�
%��'�'��,�,�,�,�,�
�|�
#�
#��%�%�f�c�2�2�2�2�2�
�~�
%�
%��'�'���4�4�4�4�4�
��
&�
&� #�	�	���
D�
D���9��'�'�6���A����C�C�C�C�
D�
D�
�

�

�

�
�&�&�v�s�3�3�3�3�3�
�|�
#�
#��%�%�f�c�2�2�2�2�2�$�
#rc
��|jrl	t|��t|j��ksJ�nC#t$r6tdt|���dt|j���d����wxYw|jrx	t|��t|jd��ksJ�nI#t$r<tdt|���dt|jd���d����wxYw	t|��tt|����ksJ�dS#t$rtd���wxYw)Nz9Field name list has incorrect number of values, (actual) �!=� (expected)rzField names must be unique)rar �AssertionError�
ValueErrorrb�set�r�r�s  rr�z!PrettyTable._validate_field_names�s�����	�
��3�x�x�3�t�'8�#9�#9�9�9�9�9�9��!�
�
�
� �P� #�C���P�P�,/��0A�,B�,B�P�P�P����
����
�:�	�
��3�x�x�3�t�z�!�}�#5�#5�5�5�5�5�5��!�
�
�
� �L� #�C���L�L�,/��
�1�
�,>�,>�L�L�L����
����	;��s�8�8�s�3�s�8�8�}�}�,�,�,�,�,�,���	;�	;�	;��9�:�:�:�	;���s#�'1�AA1�<-B*�*AC0�4/D%�%D?c�x�	|�t|t��sJ�dSdS#t$rtd���wxYw)Nz>Replacement for None value must be a string if being supplied.)r��strr��	TypeErrorr�s  rr�z!PrettyTable._validate_none_format�s_��	���!�#�s�+�+�+�+�+���+�+���	�	�	��P���
�	���s��9c�N�	|dvsJ�dS#t$rtd���wxYw)N)�capr-�upper�lowerNz:Invalid header style, use cap, title, upper, lower or None�r�r�r�s  rr�z"PrettyTable._validate_header_style�sO��	��B�B�B�B�B�B�B���	�	�	��L���
�	���s�
�$c�V�	|dvsJ�dS#t$rtd|�d����wxYw)N)r��cr��
Alignment z is invalid, use l, c or rr�r�s  r�_validate_alignzPrettyTable._validate_align�sX��	K��/�)�)�)�)�)�)���	K�	K�	K��I�#�I�I�I�J�J�J�	K�����
�(c�V�	|dvsJ�dS#t$rtd|�d����wxYw)N)�t�m�bNr�z  is invalid, use t, m, b or Noner�r�s  r�_validate_valignzPrettyTable._validate_valign�sY��	Q��/�/�/�/�/�/�/���	Q�	Q�	Q��O�#�O�O�O�P�P�P�	Q���r�c�x�	t|��dksJ�dS#t$rtd|�d|�����wxYw)Nr�Invalid value for �: )r�r�r��r�r�r�s   rr�z%PrettyTable._validate_nonnegative_int�s]��	A��s�8�8�q�=�=�=�=�=�=���	A�	A�	A��?�$�?�?�#�?�?�@�@�@�	A���s�� 9c�V�	|dvsJ�dS#t$rtd|�d����wxYw)NrXr�z. Must be True or False.r�r�s   rr�z#PrettyTable._validate_true_or_false�sX��	R��-�'�'�'�'�'�'���	R�	R�	R��P�$�P�P�P�Q�Q�Q�	R���r�c��|dkrdS	t|t��sJ�|���sJ�dS#t$rt	d|�d����wxYw)N�r�z#. Must be an integer format string.)r�r��isdigitr�r�r�s   rr�z PrettyTable._validate_int_format�s���"�9�9��F�	��c�3�'�'�'�'�'��;�;�=�=� � �=� � ���	�	�	��N�T�N�N�N���
�	���s	�-9�Ac��|dkrdS	t|t��sJ�d|vsJ�|�d��}t|��dksJ�|ddks|d���sJ�|ddks[|d���sC|dddkr-|d�d�����sJ�dSdSdS#t$rtd|�d	����wxYw)
Nr�r�rrr����fr�z . Must be a float format string.)r�r�rr r��rstripr�r�)r�r�r��bitss    rr�z"PrettyTable._validate_float_format�s'���"�9�9��F�	��c�3�'�'�'�'�'��#�:�:�:�:��9�9�S�>�>�D��t�9�9��>�>�>�>���7�b�=�=�D��G�O�O�$5�$5�=�=�5��Q��2�
�
���7�?�?�$�$����G�B�K�3�&�&�4��7�>�>�#�+>�+>�+F�+F�+H�+H�&�&�J�
�
�
�
�&�&���	�	�	��K�T�K�K�K���
�	���s�CC&�&Dc�n�	t|d��sJ�dS#t$rtd|�d����wxYw)N�__call__r�z. Must be a function.)�hasattrr�r�r�s   rr�zPrettyTable._validate_functions]��	O��3�
�+�+�+�+�+�+�+���	O�	O�	O��M�$�M�M�M�N�N�N�	O���s��4c��	|ttttfvsJ�dS#t$rtd|�d����wxYw)Nr�z%. Must be ALL, FRAME, HEADER or NONE.)rsrq�HEADER�NONEr�r�r�s   rr�zPrettyTable._validate_hrulessb��	��3��v�t�4�4�4�4�4�4�4���	�	�	��P�T�P�P�P���
�	���s	�"�Ac�z�	|tttfvsJ�dS#t$rt	d|�d����wxYw)Nr�z. Must be ALL, FRAME, or NONE.)rsrqr�r�r�r�s   rr�zPrettyTable._validate_vruless_��	X��3��t�,�,�,�,�,�,�,���	X�	X�	X��V�$�V�V�V�W�W�W�	X���s��:c�f�	||jvs|�J�dSdS#t$rtd|�����wxYw)NzInvalid field name: )rar�r�r�s   rr�z PrettyTable._validate_field_namesZ��	;��4�,�,�,�#�+�+�>�,�,�+�+���	;�	;�	;��9�C�9�9�:�:�:�	;���s�
�0c�x�	|D]}|�||���dS#t$rtd���wxYw)Nz(Fields must be a sequence of field names)r�r�r�)r�r�r�r[s    rr�z%PrettyTable._validate_all_field_namessh��	I��
3�
3���)�)�$��2�2�2�2�
3�
3���	I�	I�	I��G�H�H�H�	I���s��9c�t�	t|��dksJ�dS#t$rtd|�d����wxYw)Nrr�z. Must be a string of length 1.)rr�r�r�s   rr�z!PrettyTable._validate_single_char#s`��	Y�#�C�(�(�A�-�-�-�-�-�-���	Y�	Y�	Y��W�$�W�W�W�X�X�X�	Y���s��7c�p�	t|t��sJ�dS#t$rtd���wxYw)Nz3Attributes must be a dictionary of name/value pairs)r��dictr�r�r�s   rr�z PrettyTable._validate_attributes)sR��	S��c�4�(�(�(�(�(�(�(���	S�	S�	S��Q�R�R�R�	S���s��5�	list[Any]c� �|jdd�Sr)rbr�s r�rowszPrettyTable.rows2s���z�!�!�!�}�r�
list[bool]c� �|jdd�Sr)rcr�s r�dividerszPrettyTable.dividers6s���~�a�a�a� � r�boolc��|jS)z,Print <br/> tags if True, <br> tags if False)r�r�s rrIzPrettyTable.xhtml:s���{�rc�@�|�d|��||_dS)NrI)rgr�r�s  rrIzPrettyTable.xhtml?�#�����g�s�+�+�+�����rc��|jSr)rlr�s rrWzPrettyTable.none_formatDs��� � rc��|js	i|_dS|�(t|t��r)t	|��dkr|jD]}d|j|<�
dS|�|��|jD]}||j|<�
dS)Nr)rarlr�r�r r��r�r��fields   rrWzPrettyTable.none_formatHs���� �	/� "�D����
�[�Z��T�2�2�[�s�3�x�x�1�}�}��*�
0�
0��+/��!�%�(�(�
0�
0�
�&�&�s�+�+�+��*�
/�
/��+.��!�%�(�(�
/�
/rc��|jS)z�List or tuple of field names

        When setting field_names, if there are already field names the new list
        of field names must be the same length. Columns are renamed and row data
        remains unchanged.)rar�s rrdzPrettyTable.field_namesTs
��� � rc�r�d�|D��}|�d|��d}|jr|jdd�}||_|jrV|rTt||��D]\}}|j||j|<�|D]%}||jvr|j�|���&n3|jr%|jD]}|jt
|j|<�nd|_|jrW|rUt||��D]\}}|j||j|<�|D]%}||jvr|j�|���&dSd|_dS)Nc�,�g|]}t|����SrZ�r��rr[s  r�
<listcomp>z+PrettyTable.field_names.<locals>.<listcomp>_s��#�#�#�!�s�1�v�v�#�#�#rrdr�r�)	rgrar��zip�pop�BASE_ALIGN_VALUErT�_valignrH)r�r��	old_names�old_name�new_name�
field_names      rrdzPrettyTable.field_names]s���#�#�s�#�#�#�����m�S�1�1�1��	���	-��)�!�!�!�,�I�����;�
	�9�
	�&)�)�S�&9�&9�
>�
>�"��(�(,��H�(=���H�%�%�%�
.�
.���4�;�.�.��K�O�O�H�-�-�-��
.��[�	�"�/�
H�
H�
�*.�+�6F�*G���J�'�'�
H��D�J��<�	�I�	�&)�)�S�&9�&9�
@�
@�"��(�)-��h�)?���X�&�&�%�
/�
/���4�<�/�/��L�$�$�X�.�.�.��
/�
/��D�K�K�Krc��|jS)zdControls alignment of fields
        Arguments:

        align - alignment, one of "l", "c", or "r" �r�r�s rrTzPrettyTable.alignys���{�rc�4�|�(t|t��r@t|��dkr-|jstdi|_dS|jD]}d|j|<�
dS|�|��|jst|i|_dS|jD]}||j|<�
dS)Nrr�)r�r�r rarr�r�r
s   rrTzPrettyTable.align�s����;�:�c�4�0�0�;�S��X�X��]�]��$�
-�/��5�����!�.�-�-�E�),�D�K��&�&�-�-�
� � ��%�%�%��$�
-�/��5�����!�.�-�-�E�),�D�K��&�&�-�-rc��|jS)zwControls vertical alignment of fields
        Arguments:

        valign - vertical alignment, one of "t", "m", or "b" )rr�s rrHzPrettyTable.valign�s���|�rc��|js	i|_dS|�(t|t��r)t	|��dkr|jD]}d|j|<�
dS|�|��|jD]}||j|<�
dS)Nrr�)rarr�r�r r�r
s   rrHzPrettyTable.valign�s���� �	*��D�L�L�L�
�[�Z��T�2�2�[�s�3�x�x�1�}�}��*�
*�
*��&)���U�#�#�
*�
*�
�!�!�#�&�&�&��*�
*�
*��&)���U�#�#�
*�
*rc��|jS)z^Controls maximum width of fields
        Arguments:

        max_width - maximum width integer)�
_max_widthr�s rrUzPrettyTable.max_width������rc��|�(t|t��rt|��dkr	i|_dS|�d|��|jD]}||j|<�
dS)NrrU)r�r�r r rgrar
s   rrUzPrettyTable.max_width��o���;�:�c�4�0�0�;�S��X�X��]�]� �D�O�O�O��!�!�+�s�3�3�3��*�
-�
-��),����&�&�
-�
-rc��|jS)z^Controls minimum width of fields
        Arguments:

        min_width - minimum width integer)�
_min_widthr�s rrVzPrettyTable.min_width�r!rc��|�(t|t��rt|��dkr	i|_dS|�d|��|jD]}||j|<�
dS)NrrV)r�r�r r%rgrar
s   rrVzPrettyTable.min_width�r#rc��|jSr)rxr�s rr>zPrettyTable.min_table_width�����$�$rc�@�|�d|��||_dS)Nr>)rgrxr�s  rr>zPrettyTable.min_table_width��'�����/��5�5�5� #����rc��|jSr)ryr�s rr?zPrettyTable.max_table_width�r(rc�@�|�d|��||_dS)Nr?)rgryr�s  rr?zPrettyTable.max_table_width�r*rc��|jS)z3List or tuple of field names to include in displays)rkr�s rr0zPrettyTable.fields�s���|�rc�@�|�d|��||_dS)Nr0)rgrkr�s  rr0zPrettyTable.fields��#�����h��,�,�,�����rc��|jS)zEOptional table title

        Arguments:

        title - table title)rhr�s rr-zPrettyTable.title�����{�rc�.�t|��|_dSr)r�rhr�s  rr-zPrettyTable.title�s���#�h�h����rc��|jS)z{Start index of the range of rows to print

        Arguments:

        start - index of first data row to include in output)rir�s rr.zPrettyTable.start�r1rc�@�|�d|��||_dS)Nr.)rgrir�s  rr.zPrettyTable.start�rrc��|jS)z�End index of the range of rows to print

        Arguments:

        end - index of last data row to include in output PLUS ONE (list slice style))rjr�s rr/zPrettyTable.end�s���y�rc�@�|�d|��||_dS)Nr/)rgrjr�s  rr/zPrettyTable.ends#�����e�S�)�)�)���	�	�	rc��|jS)z_Name of field by which to sort rows

        Arguments:

        sortby - field name to sort by)rur�s rr4zPrettyTable.sortby����|�rc�@�|�d|��||_dS)Nr4)rgrur�s  rr4zPrettyTable.sortbyr/rc��|jS)z�Controls direction of sorting (ascending vs descending)

        Arguments:

        reveresort - set to True to sort by descending order, or False to sort by
            ascending order)rvr�s rr5zPrettyTable.reversesort�
��� � rc�@�|�d|��||_dS)Nr5)rgrvr�s  rr5zPrettyTable.reversesort$�&�����m�S�1�1�1�����rc��|jS)z�Sorting key function, applied to data points before sorting

        Arguments:

        sort_key - a function which takes one argument and returns something to be
        sorted)rwr�s rr6zPrettyTable.sort_key)s���~�rc�@�|�d|��||_dS)Nr6)rgrwr�s  rr6zPrettyTable.sort_key3s#�����j�#�.�.�.�����rc��|jS)z�Controls printing of table header with field names

        Arguments:

        header - print a header showing field names (True or False))rmr�s rr1zPrettyTable.header8r8rc�@�|�d|��||_dS)Nr1)rgrmr�s  rr1zPrettyTable.headerAr/rc��|jS)z�Controls stylisation applied to field names in header

        Arguments:

        header_style - stylisation to apply to field names in header
            ("cap", "title", "upper", "lower" or None))rnr�s rrGzPrettyTable.header_styleFs
���!�!rc�>�|�|��||_dSr)r�rnr�s  rrGzPrettyTable.header_stylePs$���#�#�C�(�(�(� ����rc��|jS)z~Controls printing of border around table

        Arguments:

        border - print a border around the table (True or False))ror�s rr2zPrettyTable.borderUr8rc�@�|�d|��||_dS)Nr2)rgror�s  rr2zPrettyTable.border^r/rc��|jS)z�Controls printing of border inside table

        Arguments:

        preserve_internal_border - print a border inside the table even if
            border is disabled (True or False))rpr�s rr3z$PrettyTable.preserve_internal_bordercs
���-�-rc�@�|�d|��||_dS)Nr3)rgrpr�s  rr3z$PrettyTable.preserve_internal_borderms'�����8�#�>�>�>�),��&�&�&rc��|jS)z�Controls printing of horizontal rules after rows

        Arguments:

        hrules - horizontal rules style.  Allowed values: FRAME, ALL, HEADER, NONE)rrr�s rr9zPrettyTable.hrulesrr8rc�@�|�d|��||_dS)Nr9)rgrrr�s  rr9zPrettyTable.hrules{r/rc��|jS)z�Controls printing of vertical rules between columns

        Arguments:

        vrules - vertical rules style.  Allowed values: FRAME, ALL, NONE)rtr�s rr:zPrettyTable.vrules�r8rc�@�|�d|��||_dS)Nr:)rgrtr�s  rr:zPrettyTable.vrules�r/rc��|jS)zbControls formatting of integer data
        Arguments:

        int_format - integer format string)�_int_formatr�s rr;zPrettyTable.int_format�s
����rc��|�(t|t��rt|��dkr	i|_dS|�d|��|jD]}||j|<�
dS)Nrr;)r�r�r rMrgrar
s   rr;zPrettyTable.int_format�ss���;�:�c�4�0�0�;�S��X�X��]�]�!�D�����!�!�,��4�4�4��*�
.�
.��*-�� ��'�'�
.�
.rc��|jS)zrControls formatting of floating point data
        Arguments:

        float_format - floating point format string)�
_float_formatr�s rr<zPrettyTable.float_format�s
���!�!rc��|�(t|t��rt|��dkr	i|_dS|�d|��|jD]}||j|<�
dS)Nrr<)r�r�r rPrgrar
s   rr<zPrettyTable.float_format�ss���;�:�c�4�0�0�;�S��X�X��]�]�!#�D�����!�!�.�#�6�6�6��*�
0�
0��,/��"�5�)�)�
0�
0rc��|jS)z�Controls formatting of any column using callable
        Arguments:

        custom_format - Dictionary of field_name and callable)�_custom_formatr�s rr=zPrettyTable.custom_format�s
���"�"rc�P�|�	i|_dSt|t��r<|���D]\}}|�d|��|���||_dSt|d��r,|�d|��|jD]}||j|<�
dStd���)Nz
custom_value.r��custom_valuez>The custom_format property need to be a dictionary or callable)rSr�r�r�r�r�rar�)r�r�r��vrs     rr=zPrettyTable.custom_format�s����;�"$�D����
��T�
"�
"�	��	�	���
@�
@���1��'�'�(;��(;�(;�Q�?�?�?�?�"%�D����
�S�*�
%�
%�	��#�#�N�C�8�8�8��*�
1�
1��-0��#�E�*�*�
1�
1��P���
rc��|jS)z�The number of empty spaces between a column's edge and its content

        Arguments:

        padding_width - number of spaces, must be a positive integer)rzr�s rr@zPrettyTable.padding_width��
���"�"rc�@�|�d|��||_dS)Nr@)rgrzr�s  rr@zPrettyTable.padding_width�s&�����o�s�3�3�3�!����rc��|jS)z�The number of empty spaces between a column's left edge and its content

        Arguments:

        left_padding - number of spaces, must be a positive integer)r{r�s rrAzPrettyTable.left_padding_width�s
���'�'rc�@�|�d|��||_dS)NrA)rgr{r�s  rrAzPrettyTable.left_padding_width�s'�����2�C�8�8�8�#&�� � � rc��|jS)z�The number of empty spaces between a column's right edge and its content

        Arguments:

        right_padding - number of spaces, must be a positive integer)r|r�s rrBzPrettyTable.right_padding_width�s
���(�(rc�@�|�d|��||_dS)NrB)rgr|r�s  rrBzPrettyTable.right_padding_width�s'�����3�S�9�9�9�$'��!�!�!rc��|jS)z�The character used when printing table borders to draw vertical lines

        Arguments:

        vertical_char - single character string used to draw vertical lines)r}r�s rrCzPrettyTable.vertical_char�rXrc�^�t|��}|�d|��||_dS)NrC)r�rgr}r�s  rrCzPrettyTable.vertical_char��1���#�h�h�����o�s�3�3�3�!����rc��|jS)z�The character used when printing table borders to draw horizontal lines

        Arguments:

        horizontal_char - single character string used to draw horizontal lines)r~r�s rrDzPrettyTable.horizontal_chars
���$�$rc�^�t|��}|�d|��||_dS)NrD)r�rgr~r�s  rrDzPrettyTable.horizontal_chars2���#�h�h�����/��5�5�5� #����rc��|jp|jS)z�The character used to indicate column alignment in horizontal lines

        Arguments:

        horizontal_align_char - single character string used to indicate alignment�r�rFr�s rrEz!PrettyTable.horizontal_align_chars���.�D�$�2D�Drc�^�t|��}|�d|��||_dS)NrE)r�rgrr�s  rrEz!PrettyTable.horizontal_align_chars2���#�h�h�����5�s�;�;�;�&)��#�#�#rc��|jS)z�The character used when printing table borders to draw line junctions

        Arguments:

        junction_char - single character string used to draw line junctions)r�r�s rrFzPrettyTable.junction_char rXrc�^�t|��}|�d|��||_dS)NrF)r�rgr�r�s  rrFzPrettyTable.junction_char)r`rc��|jp|jS)z�The character used when printing table borders to draw top line junctions

        Arguments:

        top_junction_char - single character string used to draw top line junctions)r�rFr�s rrLzPrettyTable.top_junction_char/s���&�<�$�*<�<rc�^�t|��}|�d|��||_dS)NrL)r�rgr�r�s  rrLzPrettyTable.top_junction_char8s2���#�h�h�����1�3�7�7�7�"%����rc��|jp|jS)z�The character used when printing table borders to draw bottom line junctions

        Arguments:

        bottom_junction_char -
            single character string used to draw bottom line junctions)r�rFr�s rrMz PrettyTable.bottom_junction_char>s���)�?�T�-?�?rc�^�t|��}|�d|��||_dS)NrM)r�rgr�r�s  rrMz PrettyTable.bottom_junction_charHs2���#�h�h�����4�c�:�:�:�%(��"�"�"rc��|jp|jS)z�The character used when printing table borders to draw right line junctions

        Arguments:

        right_junction_char -
            single character string used to draw right line junctions)r�rFr�s rrNzPrettyTable.right_junction_charNs���(�>�D�,>�>rc�^�t|��}|�d|��||_dS)NrN)r�rgr�r�s  rrNzPrettyTable.right_junction_charXs2���#�h�h�����3�S�9�9�9�$'��!�!�!rc��|jp|jS)z�The character used when printing table borders to draw left line junctions

        Arguments:

        left_junction_char - single character string used to draw left line junctions)r�rFr�s rrOzPrettyTable.left_junction_char^s���'�=�4�+=�=rc�^�t|��}|�d|��||_dS)NrO)r�rgr�r�s  rrOzPrettyTable.left_junction_chargs2���#�h�h�����2�C�8�8�8�#&�� � � rc��|jp|jS)z�
        The character used when printing table borders to draw top-right line junctions

        Arguments:

        top_right_junction_char -
            single character string used to draw top-right line junctions)r�rFr�s rrPz#PrettyTable.top_right_junction_charms���,�B��0B�Brc�^�t|��}|�d|��||_dS)NrP)r�rgr�r�s  rrPz#PrettyTable.top_right_junction_charxs2���#�h�h�����7��=�=�=�(+��%�%�%rc��|jp|jS)z�
        The character used when printing table borders to draw top-left line junctions

        Arguments:

        top_left_junction_char -
            single character string used to draw top-left line junctions)r�rFr�s rrQz"PrettyTable.top_left_junction_char~s���+�A�t�/A�Arc�^�t|��}|�d|��||_dS)NrQ)r�rgr�r�s  rrQz"PrettyTable.top_left_junction_char�s2���#�h�h�����6��<�<�<�'*��$�$�$rc��|jp|jS)z�The character used when printing table borders
           to draw bottom-right line junctions

        Arguments:

        bottom_right_junction_char -
            single character string used to draw bottom-right line junctions)r�rFr�s rrRz&PrettyTable.bottom_right_junction_char�s���/�E�4�3E�Erc�^�t|��}|�d|��||_dS)NrR)r�rgr�r�s  rrRz&PrettyTable.bottom_right_junction_char�s2���#�h�h�����:�C�@�@�@�+.��(�(�(rc��|jp|jS)z�The character used when printing table borders
           to draw bottom-left line junctions

        Arguments:

        bottom_left_junction_char -
            single character string used to draw bottom-left line junctionsrdr�s rrSz%PrettyTable.bottom_left_junction_char�s���.�D�$�2D�Drc�^�t|��}|�d|��||_dS)NrS)r�rgr�r�s  rrSz%PrettyTable.bottom_left_junction_char�s2���#�h�h�����9�3�?�?�?�*-��'�'�'rc��|jS)z~Controls whether or not HTML tables are formatted to match styling options

        Arguments:

        format - True or False)r�r�s rr8zPrettyTable.format�r8rc�@�|�d|��||_dS)Nr8)rgr�r�s  rr8zPrettyTable.format�r/rc��|jS)z�Controls whether or not empty tables produce a header and frame or just an
        empty string

        Arguments:

        print_empty - True or False)r�r�s rrJzPrettyTable.print_empty�r;rc�@�|�d|��||_dS)NrJ)rgr�r�s  rrJzPrettyTable.print_empty�r=rc��|jS)z�A dictionary of HTML attribute name/value pairs to be included in the
        <table> tag when printing HTML

        Arguments:

        attributes - dictionary of attributes)r�r�s rr7zPrettyTable.attributes�s
����rc�@�|�d|��||_dS)Nr7)rgr�r�s  rr7zPrettyTable.attributes�s&�����l�C�0�0�0�����rc��|jS)z<oldsortslice - Slice rows before sorting in the "old style" )r�r�s rrKzPrettyTable.oldsortslice�s
���!�!rc�@�|�d|��||_dS)NrK)rgr�r�s  rrKzPrettyTable.oldsortslice�s&�����n�c�2�2�2� ����rc��i}|jD]A}||vr(|�|||��||||<�.t||��||<�B|Sr)rfrgr�)r�r��optionsr�s    r�_get_optionszPrettyTable._get_options�sf�����m�	8�	8�F������%�%�f�f�V�n�=�=�=�"(��.�����")�$��"7�"7������rc�0�|tkr|���dS|tkr|���dS|tkr|���dS|tkr|���dS|tkr|�	��dS|tkr|���dS|tkr|�
��dS|tkr|���dSt!d���)NzInvalid pre-set style)�DEFAULT�_set_default_style�MSWORD_FRIENDLY�_set_msword_style�
PLAIN_COLUMNS�_set_columns_style�MARKDOWN�_set_markdown_style�ORGMODE�_set_orgmode_style�
DOUBLE_BORDER�_set_double_border_style�
SINGLE_BORDER�_set_single_border_style�RANDOM�_set_random_styler�)r��styles  r�	set_stylezPrettyTable.set_style�s'���G����#�#�%�%�%�%�%�
�o�
%�
%��"�"�$�$�$�$�$�
�m�
#�
#��#�#�%�%�%�%�%�
�h�
�
��$�$�&�&�&�&�&�
�g�
�
��#�#�%�%�%�%�%�
�m�
#�
#��)�)�+�+�+�+�+�
�m�
#�
#��)�)�+�+�+�+�+�
�f�_�_��"�"�$�$�$�$�$��4�5�5�5rc�<�|���d|_dS)NT)r��orgmoder�s rr�zPrettyTable._set_orgmode_style
s�����!�!�!�����rc��d|_d|_d|_d|_d|_d|_d|_d|_d|_dS)NTrr]�:)	r1r2rrr@rArBrCrFrr�s rr�zPrettyTable._set_markdown_stylesM��������������"#���#$�� � ��� ���&)��#�#�#rc�$�d|_d|_t|_t|_d|_d|_d|_d|_	d|_
d|_d|_d|_
d|_d|_d|_d|_d|_d|_d|_dS)NTrr]r^r_)r1r2rqrrrsrtr@rArBrCrDrrFr�r�r�r�r�r�r�r�r�s rr�zPrettyTable._set_default_styles������������������"#���#$�� � ���"���&*��#� ���"&���%)��"�$(��!�#'�� �(,��%�'+��$�+/��(�*.��'�'�'rc�r�d|_d|_t|_d|_d|_d|_d|_dS)NTrr])r1r2r�rrr@rArBrCr�s rr�zPrettyTable._set_msword_style1s=��������������"#���#$�� � ����rc�L�d|_d|_d|_d|_d|_dS)NTFrr�)r1r2r@rArBr�s rr�zPrettyTable._set_columns_style:s.�����������"#���#$�� � � rc��d|_d|_d|_d|_d|_d|_d|_d|_d	|_d
|_	d|_
dS)Nu═u║u╬u╦u╩u╣u╠u╗u╔u╝u╚�rDrCrFrLrMrNrOrPrQrRrSr�s rr�z$PrettyTable._set_double_border_styleA�`��$���"���"���!&���$)��!�#(�� �"'���',��$�&+��#�*/��'�).��&�&�&rc��d|_d|_d|_d|_d|_d|_d|_d|_d	|_d
|_	d|_
dS)Nu─u│u┼u┬u┴u┤u├u┐u┌u┘u└r�r�s rr�z$PrettyTable._set_single_border_styleNr�rc�R�tjd��|_tjd��|_tjtt
ttf��|_tjtt
tf��|_	tj
dd��|_tj
dd��|_tjd��|_
tjd��|_tjd��|_tjd��|_dS)NrXr�z!~!@#$%^&*()_+|-=\{}[];':\",./;<>?)�random�choicer1r2rsrqr�r�rrrt�randintrArBrCrDrFr3r�s rr�zPrettyTable._set_random_style[s����m�M�2�2����m�M�2�2����}�c�5�&�$�%?�@�@����}�c�5�$�%7�8�8���"(�.��A�"6�"6���#)�>�!�Q�#7�#7�� �#�]�+O�P�P���%�}�-Q�R�R���#�]�+O�P�P���(.�
�m�(D�(D��%�%�%rc�:�|D]}|�|���dS)z�Add rows to the table

        Arguments:

        rows - rows of data, should be an iterable of lists, each list with as many
        elements as the table has fieldsN)r�)r�rr�s   r�add_rowszPrettyTable.add_rowsls2���	�	�C��L�L������	�	rF)�dividerc��|jrZt|��t|j��kr5tdt|���dt|j���d����|js,d�tdt|����D��|_|j�t|����|j�|��dS)z�Add a row to the table

        Arguments:

        row - row of data, should be a list with as many elements as the table
        has fieldsz-Row has incorrect number of values, (actual) r�r�c��g|]
}d|dz����S)zField rrZ)r�ns  rrz'PrettyTable.add_row.<locals>.<listcomp>�s%��M�M�M�Q� 0��Q�� 0� 0�M�M�MrrN)	rar r��rangerdrb�append�listrc)r�r�r�s   rr�zPrettyTable.add_rowvs�����	��S���S��1B�-C�-C�!C�!C��L���H�H�L�L�(+�D�,=�(>�(>�L�L�L���
�� �	N�M�M�%��3�s�8�8�:L�:L�M�M�M�D���
���$�s�)�)�$�$�$�����g�&�&�&�&�&rc��|t|j��dz
kr(td|�dt|j���d����|j|=|j|=dS)z�Delete a row from the table

        Arguments:

        row_index - The index of the row you want to delete.  Indexing starts at 0.rzCan't delete row at index z, table only has z rowsN)r rbr�rc)r��	row_indexs  r�del_rowzPrettyTable.del_row�su���s�4�:����*�*�*��9�Y�9�9�"%�d�j�/�/�9�9�9���
�
�J�y�!��N�9�%�%�%rr�r�rTr�rHc��t|j��dt|��fvr�|�|��|�|��|j�|��||j|<||j|<tdt|����D]w}t|j��|dzkr4|j�g��|j	�d��|j|�||���xdStdt|���dt|j�������)a�Add a column to the table.

        Arguments:

        fieldname - name of the field to contain the new column of data
        column - column of data, should be a list with as many elements as the
        table has rows
        align - desired alignment for this column - "l" for left, "c" for centre and
            "r" for right
        valign - desired vertical alignment for new columns - "t" for top,
            "m" for middle and "b" for bottomrrFzColumn length z does not match number of rows N)r rbr�r�rar�r�rr�rcr�)r��	fieldname�columnrTrH�is      r�
add_columnzPrettyTable.add_column�sF���t�z�?�?�q�#�f�+�+�.�.�.�� � ��'�'�'��!�!�&�)�)�)���$�$�Y�/�/�/�%*�D�K�	�"�&,�D�L��#��1�c�&�k�k�*�*�
0�
0���t�z�?�?�Q��U�*�*��J�%�%�b�)�)�)��N�)�)�%�0�0�0��
�1�
�$�$�V�A�Y�/�/�/�/�	
0�
0��%��V���%�%��t�z�?�?�%�%���
r�Indexr�c���|j�d|��|j|j|<|j|j|<t
|j��D]\}}|�d|dz���dS)z�Add an auto-incrementing index column to the table.
        Arguments:
        fieldname - name of the field to contain the new column of datarrN)ra�insertrTr�rHr�	enumeraterb)r�r�r�r�s    r�
add_autoindexzPrettyTable.add_autoindex�s{��	
�� � ��I�.�.�.�!%����I��"&�+���Y����
�+�+�	!�	!�F�A�s��J�J�q�!�a�%� � � � �	!�	!rc��||jvr@td|�dd�tt|j���������|j�|��}|j|=|jD]}||=�dS)zxDelete a column from the table

        Arguments:

        fieldname - The field name of the column you want to delete.zCan't delete column z; which is not a field name of this table. Field names are: z, N)rar��join�map�reprr�rb)r�r��	col_indexr�s    r�
del_columnzPrettyTable.del_column�s����D�-�-�-��*��9�9�d�i�i��D�$�2C�(D�(D�E�E�E�G���
��%�+�+�I�6�6�	���i�(��:�	�	�C��I���	�	rc�"�g|_g|_dS)z?Delete all rows from the table but keep the current field namesN)rbrcr�s r�
clear_rowszPrettyTable.clear_rows�s����
�����rc�>�g|_g|_g|_g|_dS)z_Delete all rows and field names from the table, maintaining nothing but
        styling optionsN)rbrcrarer�s r�clearzPrettyTable.clear�s%����
�����������rc�*�tj|��Sr)�copy�deepcopyr�s rr�zPrettyTable.copy�s���}�T�"�"�"rr"�
out_formatc���|dkr
|jd	i|��S|dkr
|jd	i|��S|dkr
|jd	i|��S|dkr
|jd	i|��S|dkr
|jd	i|��Std|�d����)
z�Return string representation of specified format of table in current state.

        Arguments:
        out_format - resulting table format
        kwargs - passed through to function that performs formatting
        r"�html�json�csv�latexzInvalid format z1. Must be one of: text, html, json, csv, or latexNrZ)r�r��get_json_string�get_csv_string�get_latex_stringr�)r�r�r�s   r�get_formatted_stringz PrettyTable.get_formatted_string�s�������"�4�?�,�,�V�,�,�,�����'�4�'�1�1�&�1�1�1�����'�4�'�1�1�&�1�1�1�����&�4�&�0�0��0�0�0��� � �(�4�(�2�2�6�2�2�2��
>�j�
>�
>�
>�
�
�	
rc��t|t��r||jvrd|j|z|zSt|t��r||jvrd|j|z|zS|j�|d���}|||��S)Nz%%%sdz%%%sfc� �t|��Srr)r�rVs  rr\z+PrettyTable._format_value.<locals>.<lambda>
s���Q���r)r�r�rM�floatrPrSr`)r�r�valuer�s    r�
_format_valuezPrettyTable._format_values����e�S�!�!�	A�e�t�/?�&?�&?��d�.�u�5�5��>�>�
��u�
%�
%�	A�%�4�3E�*E�*E��d�0��7�7�5�@�@��'�+�+�E�4G�4G�I�I�	��y���&�&�&rc��|dttfvrdnd}t|�|����}t	|j��D]2\}}|dr|dr||dvr||j||zz
}�3|S)Nr:rrr0)rqrs�sum�_get_padding_widthsr�rdre)r�r��table_width�per_col_paddingr�r�s      r�_compute_table_widthz PrettyTable._compute_table_width
s���"�8�,����<�<�a�a�!���d�6�6�w�?�?�@�@�� )�$�*:� ;� ;�	E�	E��E�9��8�$�
E���!�
E�&/�7�8�3D�&D�&D��t�|�E�2�_�D�D����rc
������drd��jD��}nt�j��dgz}|D�]	}t|��D]�\}}�j|}�j�|���"|dks|��j�|��}|�jvrFt||tt|��d�j|����||<n,t||t|��d��||<|�j
vr$t||�j
|��||<����|�_�jrB��
���}|�jkr"d�jz|z��fd�|D��}|�_�js	�d�r7�drTt�d��t�������z}	�dt"t$fvr|	d	z
}	nd}	�jpd}
t|	|
��}�d
rt|��dz}n�drt|��}nd}|t��fd
�|D����|zz}t|��pd}
|
|krTd|z|
z��fd�|D��}t|��|kr |dxx|t|��z
z
cc<|�_dSdSdS)Nr1c�8�g|]}t|��d��S�r)r&)rrs  rrz/PrettyTable._compute_widths.<locals>.<listcomp>s%��I�I�I�e�i��&�&�q�)�I�I�Irrr*g�?c�X��g|]&}ttj|�z������'SrZ�r��math�floor�r�w�scales  �rrz/PrettyTable._compute_widths.<locals>.<listcomp>4�/���E�E�E��#�d�j��U��3�3�4�4�E�E�Err-r:rr2rr3c�T��g|]$}t���������%SrZ)r�r�)rr�r�r�s  ��rrz/PrettyTable._compute_widths.<locals>.<listcomp>Ls/���L�L�L��S��1�1�'�:�:�;�;�L�L�Lrc�X��g|]&}ttj|�z������'SrZr�r�s  �rrz/PrettyTable._compute_widths.<locals>.<listcomp>Tr�rr�)rar rdr�rWr`rUr!�minr&rVreryr�rxr�r�rqrsr>)r�rr��widthsr�r�r�r�r��title_widthr>rV�borders�
content_widthr�s` `           @r�_compute_widthszPrettyTable._compute_widthssa������8��	1�I�I�t�7H�I�I�I�F�F���)�*�*�a�S�0�F��	R�	R�C� )�#���

R�

R���u� �,�U�3�	��#�'�'�	�2�2�>�����%�-� $� 0� 4� 4�Y� ?� ?�����.�.�$'��u�
��I�e�,�,�Q�/���	�1J�K�K�%�%�F�5�M�M�
%(��u�
�y��7G�7G��7J�$K�$K�F�5�M����.�.�$'��u�
�t�~�i�7P�$Q�$Q�F�5�M��

R����� �	&��3�3�G�<�<�K��T�2�2�2��d�3�3�k�A��E�E�E�E�f�E�E�E��%���� �	&�G�G�$4�	&��w��
 �!�'�'�"2�3�3�c��,�,�W�5�5�7�7����8�$����4�4��1�$�K����"�2�7�a�O��K��9�9�I��x� �
��f�+�+��/����3�4�
��f�+�+�����
��L�L�L�L�L�V�L�L�L�M�M�PW�W�
�I� ��K�K�,�1�M��y�(�(��i��-�7��E�E�E�E�f�E�E�E���v�;�;��*�*��2�J�J�J�)�c�&�k�k�"9�9�J�J�J�%�����?	&�	&�2)�(rc�n�|d�	|d}n|d}|d�	|d}n|d}||fS)NrAr@rBrZ)r�r��lpad�rpads    rr�zPrettyTable._get_padding_widthsYsR���'�(�4��/�0�D�D��?�+�D��(�)�5��0�1�D�D��?�+�D��T�z�rc���|dr.tj|j|d|d���}ntj|j��}|dr]|j�|d����fd�|D��}|�|d|d���d	�|D��}|ds||d|d�}|S)
z�Return only those data rows that should be printed, based on slicing and
        sorting.

        Arguments:

        options - dictionary of option settings.rKr.r/r4c�(��g|]}|�g|z��SrZrZ)rr��	sortindexs  �rrz)PrettyTable._get_rows.<locals>.<listcomp>us%���;�;�;�s�S��^�$�s�*�;�;�;rr5r6)�reverse�keyc�"�g|]}|dd���
S)rNrZ)rr�s  rrz)PrettyTable._get_rows.<locals>.<listcomp>ys ��,�,�,��C����G�,�,�,r)r�r�rbrar��sort)r�r�rr�s   @r�	_get_rowszPrettyTable._get_rowsds�����>�"�	-��=���G�G�,<�w�u�~�,M�!N�O�O�D�D��=���,�,�D��8��	-��)�/�/���0A�B�B�I�;�;�;�;�d�;�;�;�D��I�I�g�m�4�'�*�:M�I�N�N�N�,�,�t�,�,�,�D��~�&�	;����(�7�5�>�9�:�D��rc���|dr.tj|j|d|d���}ntj|j��}|drd�|D��}|S)z�Return only those dividers that should be printed, based on slicing.

        Arguments:

        options - dictionary of option settings.rKr.r/r4c��g|]}d��S)FrZ)rr�s  rrz-PrettyTable._get_dividers.<locals>.<listcomp>�s��6�6�6�'��6�6�6r)r�r�rc)r�r�rs   r�
_get_dividerszPrettyTable._get_dividers�sm���>�"�	5��}�T�^�G�G�4D�w�u�~�4U�%V�W�W�H�H��}�T�^�4�4�H��8��	7�6�6�X�6�6�6�H��rc�F���fd�t�j|��D��S)Nc�B��g|]\}}��||����SrZ)r�)rrr�r�s   �rrz+PrettyTable._format_row.<locals>.<listcomp>�s=���
�
�
����
���u�e�,�,�
�
�
r)rra)r�r�s` r�_format_rowzPrettyTable._format_row�s;���
�
�
�
�"%�d�&7��"=�"=�
�
�
�	
rc� ���fd�|D��S)Nc�:��g|]}��|����SrZ)r)rr�r�s  �rrz,PrettyTable._format_rows.<locals>.<listcomp>�s'���6�6�6�#�� � ��%�%�6�6�6rrZ)r�rs` r�_format_rowszPrettyTable._format_rows�s���6�6�6�6��6�6�6�6rc
��|�|��}g}|jdkr|dr|dsdS|�|��}|�|��}|�|��}|�||��|�|��|_|dp|j}|r)|�	|�
||����|dr)|�	|�|����n�|dr{|dttfvre|�	|�|d�	����|r9|d
ttfvr#|j|ddd�z|jz|d<t!|d
d�|d
d���D]`\}}	|�	|�|||j����|	r*|�	|�|d�	�����a|rE|�	|�|d||�|d�	������|dr;|dtkr*|�	|�|d�	����d|jvrP|jdurGt)��}
|D]*}|
�|�d�����+d�|
D��}d�|��S)a�
Return string representation of table in current state.

        Arguments:

        title - optional table title
        start - index of first data row to include in output
        end - index of last data row to include in output PLUS ONE (list slice style)
        fields - names of fields (columns) to include
        header - print a header showing field names (True or False)
        border - print a border around the table (True or False)
        preserve_internal_border - print a border inside the table even if
            border is disabled (True or False)
        hrules - controls printing of horizontal rules after rows.
            Allowed values: ALL, FRAME, HEADER, NONE
        vrules - controls printing of vertical rules between columns.
            Allowed values: FRAME, ALL, NONE
        int_format - controls formatting of integer data
        float_format - controls formatting of floating point data
        custom_format - controls formatting of any column using callable
        padding_width - number of spaces on either side of column data (only used if
            left and right paddings are None)
        left_padding_width - number of spaces on left hand side of column data
        right_padding_width - number of spaces on right hand side of column data
        vertical_char - single character string used to draw vertical lines
        horizontal_char - single character string used to draw horizontal lines
        horizontal_align_char - single character string used to indicate alignment
        junction_char - single character string used to draw line junctions
        junction_char - single character string used to draw line junctions
        top_junction_char - single character string used to draw top line junctions
        bottom_junction_char -
            single character string used to draw bottom line junctions
        right_junction_char - single character string used to draw right line junctions
        left_junction_char - single character string used to draw left line junctions
        top_right_junction_char -
            single character string used to draw top-right line junctions
        top_left_junction_char -
            single character string used to draw top-left line junctions
        bottom_right_junction_char -
            single character string used to draw bottom-right line junctions
        bottom_left_junction_char -
            single character string used to draw bottom-left line junctions
        sortby - name of field to sort rows by
        sort_key - sorting key function, applied to data points before sorting
        reversesort - True or False to sort in descending or ascending order
        print empty - if True, stringify just the header for an empty table,
            if False return an empty stringrrJr2r�r-r1r9�top_)�wherer:r�rN�bottom_r�Trc�.�g|]}d|dd�zdz��S)r]rr�rZrs  rrz*PrettyTable.get_string.<locals>.<listcomp>s*��<�<�<��S�4��"��:�%��+�<�<�<r)r�r�r�r�rr��_stringify_hrule�_hrulerhr��_stringify_title�_stringify_headerrsrqrOrNr�_stringify_row�__dict__r�r��extendrr�)r�r�r�r#rr�formatted_rowsr-r�r��tmprs            rr�zPrettyTable.get_string�s9��`�#�#�F�+�+�����=�A���w�}�'=��W�X�EV���2��~�~�g�&�&���%�%�g�.�.���*�*�4�0�0��	
���^�W�5�5�5��+�+�G�4�4����� �/�D�K���	@��L�L��.�.�u�g�>�>�?�?�?��8��	��L�L��/�/��8�8�9�9�9�9�
�X�
�	�7�8�#4��e��#D�#D��L�L��.�.�w�f�.�E�E�F�F�F��
���*�s�E�l�:�:��+�e�B�i��"��o�=��@X�X��b�	�
 ��s��s� 3�X�c�r�c�]�C�C�	N�	N�L�C���L�L��,�,�S�'�4�;�G�G�H�H�H��
N����T�2�2�7�)�2�L�L�M�M�M���	��L�L��#�#�"�2�&���)�)�'��)�C�C���
�
�
��8��	J���!2�e�!;�!;��L�L��.�.�w�i�.�H�H�I�I�I���
�%�%�$�,�$�*>�*>��&�&�C��
-�
-���
�
�4�:�:�d�+�+�,�,�,�,�<�<��<�<�<�E��y�y����rr�c���|ds
|dsdS|�|��\}}|dttfvr
||dzg}n	|dg}|js3|�||dz��d�|��St
|j|j��D]�\}}|dr||dvr�||z|z|dz}|jrB|j	|d	vr|j|d
d�z}|j	|dvr|dd�|jz}|�|��|dtkr|�||d
z����|�|d����|dttfvr2|�
��|�||dz��|dr|ds
|d
d�}d�|��S)Nr2r3r�r:rOrDrNr0)r�r�r)r�r�r�rF)r�rsrqrar�r�rrerr�r)	r�r�rr�r�r�rr%rs	         rrzPrettyTable._stringify_hrules.���x� �	��1K�)L�	��2��-�-�g�6�6�
��d��8���e��,�,��E�$8�8�9�:�D�D��-�.�/�D�� �	!��K�K���(=� =�>�?�?�?��7�7�4�=�=� ��� 1�4�<�@�@�	8�	8�L�E�5��x� �
�U�'�(�2C�%C�%C���D�L�4�'�7�3D�+E�E�D��*�
C��;�u�%��3�3��6��a�b�b��A�D��;�u�%��3�3�����9�t�'B�B�D��K�K������x� �C�'�'����G�E�O�$;�<�=�=�=�=����G�$5�6�7�7�7�7��8���e��,�,��H�H�J�J�J��K�K���(=� =�>�?�?�?��-�.�	�w�x�7H�	���"��:�D��w�w�t�}�}�rc��g}|�|��\}}|dr�|dtkr>t|d<|�|�|d����t|d<n:|dtkr)|�|�|d����g}|dttfvr|dr|dnd}|�|��d|z|zd|zz}|�|�|t
|j��dz
d����|�|��|�d�|����d	�|��S)
Nr2r:rrCr�rr�r�r)	r�rsrqr�rr�r rr�)r�r-r�r#r�r�r��endpoints        rr
zPrettyTable._stringify_title3s}�����-�-�g�6�6�
��d��8��	E��x� �C�'�'�$)���!����T�2�2�7�F�C�C�D�D�D�$'���!�!���"�e�+�+����T�2�2�7�F�C�C�D�D�D����x� �S�%�L�0�0�W�X�5F�0�
�O�$�$��	�
	
���H�����d�
�U�"�S�4�Z�/�����D�M�M�%��T�[�)9�)9�A�)=�s�C�C�D�D�D����H����
���R�W�W�T�]�]�#�#�#��y�y����rc
�6�g}|�|��\}}|dr�|dttfvr|�|�|d����|dr9|dttfvr#|j|ddd�z|jz|d<|�d��|dttfvr|�|d	��n|�d
��|jsG|dttfvr|�|d	��n|�d
��t|j|j	��D�]L\}}|dr||dvr�|j
dkr|���}nb|j
dkr|���}nB|j
d
kr|�
��}n"|j
dkr|���}n|}t|��|kr
|d|�}|�d
|z|�|||j|��zd
|zz��|ds|drC|dtkr|�|d	����7|�d
����N|ds1|dr)|���|�d
��|dr@|dtkr/|���|�|d	��|ds|dr@|dt&kr/|�d��|�|j��d�|��S)Nr2r9rr-r:r�rrrCr�r0r�r�r�r3r�)r�rsrqr�rrOrNrarrern�
capitalizer-r�r�rr�r�rr�rr�)r�r�r�r�r�rr%r�s        rrzPrettyTable._stringify_headerJs������-�-�g�6�6�
��d��8��
	!��x� �S�%�L�0�0����D�1�1�'�6�B�B�C�C�C��7�#����(9�c�5�\�(I�(I��/��r�(�1�R�4�.�)��2�3���H�
���D�!�!�!��x� �S�%�L�0�0����G�O�4�5�5�5�5����C� � � �� �	!��x� �S�%�L�0�0����G�O�4�5�5�5�5����C� � � ��� 1�4�<�@�@�	%�	%�L�E�5��x� �
�U�'�(�2C�%C�%C���!�U�*�*�!�,�,�.�.�	�	��#�w�.�.�!�K�K�M�M�	�	��#�w�.�.�!�K�K�M�M�	�	��#�w�.�.�!�K�K�M�M�	�	�!�	��	�*�*�U�2�2�%�f�u�f�-�	��K�K��d�
��-�-�	�5�$�+�e�2D�E�E�F���*��
�
�
�
�x� �
%�G�,F�$G�
%��8�$��+�+��K�K��� 8�9�9�9�9��K�K��$�$�$���x� �	�W�-G�%H�	��H�H�J�J�J��K�K������8��	2���!2�e�!;�!;��H�H�J�J�J��K�K���0�1�1�1��H��	%��)C�!D�	%�'��K
�
�K�K�
�K�K������K�K���$�$�$��w�w�t�}�}�rc��ttdt|����|j||j��D]�\}}}}|�d��}g}	|D]l}
|
dkr'|j�|���
|j|}
t|
��|krtj
|
|��}
|	�|
���m|	}d�|��}|||<��d}|D]}t|��d}
|
|kr|
}� g}|�|��\}}td|��D]q}|�g��|drR|dtt fvr!||�|j���V||�d���rt|j||j��D�]S\}}}|j|}|�d��}|t|��z
}|rS|dkr4d	gt'|d
z��z|zd	g|t'|d
z��z
zz}n|dkr
d	g|z|z}n	|d	g|zz}d}|D]�}
|dr||dvr�||�d|z|�|
||j|��zd|zz��|ds|d
rM|dtkr!||�|j��n||�d��|dz
}����U|ds=|d
r5|d���|d�d��td|��D]V}|drL|dt kr;||���||�|d���W|drM|dtkr<||dz
�d��||dz
�|��td|��D] }d	�||��||<�!d�|��S)Nrrr*rr2r:r�r�r�rr�r0r3r�rCr9)rr�r rarerrWr`r�textwrap�fillr�r�r&r�rsrqrCrr�r�r�r)r�r�r��hruler�rr�r%r#�	new_linesr�
row_heightr��hr�r�r��yrH�d_heights                    rrzPrettyTable._stringify_row�s���*-��!�S��X�X���� 1�3���+
�+
�	�	�&�E�5�%���K�K��%�%�E��I��
'�
'���6�>�>�d�&6�&:�&:�5�&A�&A�&M��+�E�2�D�#�D�)�)�E�1�1�#�=��u�5�5�D�� � ��&�&�&�&��E��I�I�e�$�$�E��C��J�J��
��	�	�A��!���Q��A��:�~�~��
�����-�-�g�6�6�
��d��q�*�%�%�	(�	(�A��K�K��O�O�O��x� �
(��8�$��e��4�4���G�N�N�4�#5�6�6�6�6���G�N�N�3�'�'�'��#&�t�'8�#�t�|�#L�#L�	�	��E�5�%��\�%�(�F��K�K��%�%�E�!�C��J�J�.�H��

4��S�=�=���s�8�a�<�0�0�0�� ��$�(�S��A��->�->�">�?�@��E�
�s�]�]��D�8�O�e�3�E�E�!�R�D�8�O�3�E��A��
�
���8�$���g�h�6G�)G�)G���Q�����$�J��m�m�D�%���U�1C�D�D�E��D�j�!����
�8�$�,��0J�(K�,��x�(�C�/�/��Q����t�'9�:�:�:�:��Q����s�+�+�+��Q����
�$�x� �	!�W�-G�%H�	!���H�L�L�N�N�N���H�O�O�C� � � ��q�*�%�%�	9�	9�A��x� �
9�W�X�%6�%�%?�%?��Q����
�
�
��Q����w��7�8�8�8���8��	/���!2�c�!9�!9���a�� �'�'��-�-�-���a�� �'�'��.�.�.��q�*�%�%�	'�	'�A��g�g�d�1�g�&�&�D��G�G��y�y����r�:��page_lengthr��
line_breakc�N�g}|�dd��|d<|�d|j��}	t|d|z|��|d<|�|jdi|����|d|krn|dxx|z
cc<�Z|�|��S)Nr.rr/TrZ)r`r�r�r�r�r�)r�r$r%r��pages�true_ends      r�paginatezPrettyTable.paginate�s����� �*�*�W�a�0�0��w���:�:�e�T�]�3�3��	+���w��+� =�x�H�H�F�5�M��L�L����2�2�6�2�2�3�3�3��e�}��(�(���7�O�O�O�{�*�O�O�O�	+����u�%�%�%rc���|�|����fd�|���D��}tj��}t	j|fi|��}��d��r|�|j��|�	���D]}|�|���|�
��S)a�Return string representation of CSV formatted table in the current state

        Keyword arguments are first interpreted as table formatting options, and
        then any unused keyword arguments are passed to csv.writer(). For
        example, get_csv_string(header=False, delimiter='	') would use
        header as a PrettyTable formatting option (skip the header row) and
        delimiter as a csv.writer keyword argument.
        c�$��i|]\}}|�v�	||��
SrZrZ�rr�r�r�s   �r�
<dictcomp>z.PrettyTable.get_csv_string.<locals>.<dictcomp>�s0���
�
�
�%�3��3�g�;M�;M�C��;M�;M�;Mrr1)r�r��io�StringIOr��writerr`�writerowrar��getvalue)r�r��csv_options�
csv_buffer�
csv_writerr�r�s      @rr�zPrettyTable.get_csv_string�s�����#�#�F�+�+��
�
�
�
�)/�����
�
�
���[�]�]�
��Z�
�:�:�k�:�:�
��;�;�x� � �	3����� 1�2�2�2��>�>�'�*�*�	%�	%�C�����$�$�$�$��"�"�$�$�$rc	����|�|���tddd���}|��fd�|���D����g}��d��r|�|j��|����D]7}|�tt|j	|�������8tj|fi|��S)a�Return string representation of JSON formatted table in the current state

        Keyword arguments are first interpreted as table formatting options, and
        then any unused keyword arguments are passed to json.dumps(). For
        example, get_json_string(header=False, indent=2) would use header as
        a PrettyTable formatting option (skip the header row) and indent as a
        json.dumps keyword argument.
        �)�,r�T)�indent�
separators�	sort_keysc�$��i|]\}}|�v�	||��
SrZrZr,s   �rr-z/PrettyTable.get_json_string.<locals>.<dictcomp>s)���O�O�O�J�C��C�w�<N�<N�S�%�<N�<N�<Nrr1)r�r��updater�r`r�rdr�rrar��dumps)r�r��json_options�objectsr�r�s     @rr�zPrettyTable.get_json_strings�����#�#�F�+�+�� ��k�T�R�R�R�����O�O�O�O�&�,�,�.�.�O�O�O�	
�	
�	
����;�;�x� � �	-��N�N�4�+�,�,�,��>�>�'�*�*�	>�	>�C��N�N�4��D�$5�s� ;� ;�<�<�=�=�=�=��z�'�2�2�\�2�2�2rc��|�|��}|dr|�|��}n|�|��}|S)a�Return string representation of HTML formatted version of table in current
        state.

        Arguments:

        title - optional table title
        start - index of first data row to include in output
        end - index of last data row to include in output PLUS ONE (list slice style)
        fields - names of fields (columns) to include
        header - print a header showing field names (True or False)
        border - print a border around the table (True or False)
        preserve_internal_border - print a border inside the table even if
            border is disabled (True or False)
        hrules - controls printing of horizontal rules after rows.
            Allowed values: ALL, FRAME, HEADER, NONE
        vrules - controls printing of vertical rules between columns.
            Allowed values: FRAME, ALL, NONE
        int_format - controls formatting of integer data
        float_format - controls formatting of floating point data
        custom_format - controls formatting of any column using callable
        padding_width - number of spaces on either side of column data (only used if
            left and right paddings are None)
        left_padding_width - number of spaces on left hand side of column data
        right_padding_width - number of spaces on right hand side of column data
        sortby - name of field to sort rows by
        sort_key - sorting key function, applied to data points before sorting
        attributes - dictionary of name/value pairs to include as HTML attributes in the
            <table> tag
        format - Controls whether or not HTML tables are formatted to match
            styling options (True or False)
        xhtml - print <br/> tags if True, <br> tags if Falser8)r��_get_formatted_html_string�_get_simple_html_string�r�r�r��strings    rr�zPrettyTable.get_html_string*sR��B�#�#�F�+�+���8��	;��4�4�W�=�=�F�F��1�1�'�:�:�F��
rc	��g}|drd}nd}dg}|dr3|dD]*}|�d|�d|d|�d����+|�d	��|�d
�|����|dp|j}|r|�d|�d
���|dr�|�d��|�d��|jD]N}|dr||dvr�|�dt	|���d|��z���O|�d��|�d��|�d��|�|��}|�|��}	|	D]�}
|�d��t|j|
��D]Q\}}|dr||dvr�|�dt	|���d|��z���R|�d����|�d��|�d��d�|��S)NrI�<br/>�<br>�<tabler7r��="�"�>r�r-�
    <caption>�
</caption>r1�    <thead>�        <tr>r0z            <th>%s</th>r�
        </tr>�    </thead>�    <tbody>z            <td>%s</td>�    </tbody>�</table>)	r�r�rhrar�replacer�rr)r�r�r#�	linebreak�open_tag�	attr_namer-rrrr��datums            rrCz#PrettyTable._get_simple_html_stringTs������7��	��I�I��I��:���<� �	V�$�\�2�
V�
V�	���� T�I� T� T���1F�y�1Q� T� T� T�U�U�U�U��������
���R�W�W�X�&�&�'�'�'��� �/�D�K���	<��L�L�:��:�:�:�;�;�;��8��
	)��L�L��'�'�'��L�L��(�(�(��*�
�
���8�$���g�h�6G�)G�)G�����-��u�
�
�0E�0E�d�I�0V�0V�V�����
�L�L��)�)�)��L�L��(�(�(�	���]�#�#�#��~�~�g�&�&���*�*�4�0�0��!�	*�	*�C��L�L��(�(�(� #�D�$5�s� ;� ;�
�
���u��8�$���g�h�6G�)G�)G�����-��u�
�
�0E�0E�d�I�0V�0V�V�����
�L�L��)�)�)�)�
���^�$�$�$�
���Z� � � ��y�y����rc
���g}|�|��\}}|drd}nd}dg}|d�rD|dtkr(|dtkr|�d���n|dtkr'|dtkr|�d	��n�|dtkr'|dtkr|�d
��n�|dtkr|�d��nt|dtkr|�d��nM|dtkr|�d
��n&|dtkr|�d��|ds|dr|�d��|dr3|dD]*}|�d|�d|d|�d����+|�d��|�d�|����|dp|j}|r|�d|�d���|dr�|�d��|�d��|jD]Q}	|dr|	|dvr�|�d||t|	���d|��fz���R|�d ��|�d!��|�d"��|�	|��}
|�
|
��}g}g}
|jD]V}	|�d#d$d%d&�|j|	��|
�d'd(d)d*�|j|	���W|D]�}|�d��t|j|||
��D]X\}	}}}|dr|	|dvr�|�d+||||t|���d|��fz���Y|�d ����|�d,��|�d-��d�|��S).NrIrGrHrIr2r9r:z frame="box" rules="all"z frame="box"z frame="box" rules="cols"z frame="hsides"z frame="hsides" rules="rows"z frame="vsides"z frame="vsides" rules="cols"r3z
 rules="cols"r7r�rJrKrLr�r-rMrNr1rOrPr0z[            <th style="padding-left: %dem; padding-right: %dem; text-align: center">%s</th>rrQrRrS�left�right�center)r�r�r��top�middle�bottom)r�r�r�zk            <td style="padding-left: %dem; padding-right: %dem; text-align: %s; vertical-align: %s">%s</td>rTrU)r�rsr�rqr�rhrarrVr�rr�rr)r�r�r#r�r�rWrXrYr-rrr�aligns�valignsr�rZrTrHs                  rrBz&PrettyTable._get_formatted_html_string�s�����-�-�g�6�6�
��d��7��	��I�I��I��:���8��	@��x� �C�'�'�G�H�,=��,D�,D���� :�;�;�;�;���"�e�+�+���0A�U�0J�0J�����/�/�/�/���"�e�+�+���0A�S�0H�0H���� ;�<�<�<�<���"�e�+�+���� 1�2�2�2�2���"�c�)�)���� >�?�?�?�?���"�e�+�+���� 1�2�2�2�2���"�c�)�)���� >�?�?�?��x� �	-�W�-G�%H�	-��O�O�O�,�,�,��<� �	V�$�\�2�
V�
V�	���� T�I� T� T���1F�y�1Q� T� T� T�U�U�U�U��������
���R�W�W�X�&�&�'�'�'��� �/�D�K���	<��L�L�:��:�:�:�;�;�;��8��	)��L�L��'�'�'��L�L��(�(�(��*�
�
���8�$���g�h�6G�)G�)G�����q��T�6�%�=�=�#8�#8��y�#I�#I�J�K�����
�L�L��)�)�)��L�L��(�(�(�	���]�#�#�#��~�~�g�&�&���*�*�4�0�0�������&�	�	�E��M�M��7��:�:�4�;�u�;M�N�
�
�
�
�N�N��(��:�:�4�<��;N�O�
�
�
�
�"�	*�	*�C��L�L��(�(�(�/2��!�3���0�0�
�
�+��u�e�V��8�$���g�h�6G�)G�)G�����B������u�
�
�-�-�d�I�>�>���	�	�	�	�
�L�L��)�)�)�)�
���^�$�$�$�
���Z� � � ��y�y����rc��|�|��}|dr|�|��}n|�|��}|S)a�Return string representation of LaTex formatted version of table in current
        state.

        Arguments:

        start - index of first data row to include in output
        end - index of last data row to include in output PLUS ONE (list slice style)
        fields - names of fields (columns) to include
        header - print a header showing field names (True or False)
        border - print a border around the table (True or False)
        preserve_internal_border - print a border inside the table even if
            border is disabled (True or False)
        hrules - controls printing of horizontal rules after rows.
            Allowed values: ALL, FRAME, HEADER, NONE
        vrules - controls printing of vertical rules between columns.
            Allowed values: FRAME, ALL, NONE
        int_format - controls formatting of integer data
        float_format - controls formatting of floating point data
        sortby - name of field to sort rows by
        sort_key - sorting key function, applied to data points before sorting
        format - Controls whether or not HTML tables are formatted to match
            styling options (True or False)
        r8)r��_get_formatted_latex_string�_get_simple_latex_stringrDs    rr�zPrettyTable.get_latex_string�sQ��0�#�#�F�+�+���8��	<��5�5�g�>�>�F�F��2�2�7�;�;�F��
rc�|���	�g}g�	�dr�fd��jD���	n�j�	d��fd��	D����}d|z}|�|���dr+|�d��	��dz�������}��|��}|D]N}�	fd	�t�j|��D��}|�d�|��dz���O|�d
��d�|��S)Nr0c�(��g|]}|�dv�|��S�r0rZ�rrr�s  �rrz8PrettyTable._get_simple_latex_string.<locals>.<listcomp>	�/����������AR�8R�8R��8R�8R�8Rrr�c�*��g|]}�j|��SrZr�rrr�s  �rrz8PrettyTable._get_simple_latex_string.<locals>.<listcomp>	s ���L�L�L�U�d�k�%�0�L�L�Lr�\begin{tabular}{%s}r1� & � \\c�"��g|]\}}|�v�	|��SrZrZ�rr��d�
wanted_fieldss   �rrz8PrettyTable._get_simple_latex_string.<locals>.<listcomp>	�.�������a��Q�-�=O�=O��=O�=O�=Or�
\end{tabular}�
)rar�r�r�rr)
r�r�r#�
alignments�	begin_cmdrrr��wanted_datarts
``       @rrfz$PrettyTable._get_simple_latex_string	s~��������
��8��	.�����#'�#4����M�M�!�-�M��W�W�L�L�L�L�m�L�L�L�M�M�
�*�Z�7�	�
���Y�����8��	>��L�L����M�2�2�W�<�=�=�=��~�~�g�&�&���*�*�4�0�0��!�	<�	<�C�����!�$�"3�S�9�9����K�
�L�L����K�0�0�7�:�;�;�;�;�
���%�&�&�&��{�{�5�!�!�!rc�4���
�g}g�
�dr�fd��jD���
n�j�
�fd��
D��}�dr'�dtkrd�|��}n;�ds�drd�|��}nd�|��}�dr�dttfvrd|zdz}d	|z}|�|���dr+�d
ttfvr|�d���dr+|�d
��
��dz���ds�dr+�d
tt
fvr|�d�������}��|��}�����}|D]|}�
fd�t�j|��D��}	|�d
�|	��dz���dr&�d
tkr|�d���}�dr&�d
tkr|�d��|�d��d�|��S)Nr0c�(��g|]}|�dv�|��SrirZrjs  �rrz;PrettyTable._get_formatted_latex_string.<locals>.<listcomp>'	rkrc�*��g|]}�j|��SrZrrms  �rrz;PrettyTable._get_formatted_latex_string.<locals>.<listcomp>-	s ���K�K�K�E�T�[��/�K�K�Krr2r:r]r3r�rnr9z\hliner1rorpc�"��g|]\}}|�v�	|��SrZrZrrs   �rrz;PrettyTable._get_formatted_latex_string.<locals>.<listcomp>J	rurrvrw)	rarsr�rqr�r�r�rr)r�r�r#�wanted_alignments�
alignment_strryrrr�rzrts``        @rrez'PrettyTable._get_formatted_latex_string"	s���������
��8��	.�����#'�#4����M�M�!�-�M�K�K�K�K�]�K�K�K���8��	7���!2�c�!9�!9��H�H�%6�7�7�M�M���"�	7�w�/I�'J�	7��H�H�%6�7�7�M�M��G�G�$5�6�6�M��8��	6���!2�s�E�l�!B�!B��-�/�#�5�M�*�]�:�	�
���Y�����8��	$���!2�s�E�l�!B�!B��L�L��#�#�#��8��	>��L�L����M�2�2�W�<�=�=�=��H��	$��)C�!D�	$�'��K
��6�]�K�K�
�L�L��#�#�#��~�~�g�&�&���*�*�4�0�0���~�~�g�&�&��!�	(�	(�C�����!�$�"3�S�9�9����K�
�L�L����K�0�0�7�:�;�;�;��x� �
(�W�X�%6�#�%=�%=����Y�'�'�'���8��	$���!2�e�!;�!;��L�L��#�#�#�
���%�&�&�&��{�{�5�!�!�!rr�r)r*)r)r�)r)r)r)r)r�r�)rTr�rHr�r)r*)r�)r�r�)r")r�r�r)r�)r)r�)r�)r"r#)r$r�r%r�)u�__name__�
__module__�__qualname__r�r�r�r�r�r�r�rgr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r��propertyrrrI�setterrWrdrTrHrUrVr>r?r0r-r.r/r4r5r6r1rGr2r3r9r:r;r<r=r@rArBrCrDrErFrLrMrNrOrPrQrRrSr8rJr7rKr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrr�rr
rrr)r�r�r�rCrBr�rfrerZrrr(r(Ms�������G6�G6�G6�G6�G6�RH�H�H�*'�'�'�
�
�
�!�!�!�!�!�!�&�&�&�(?3�?3�?3�B;�;�;�0������K�K�K�Q�Q�Q�A�A�A�R�R�R�	�	�	����&O�O�O����X�X�X�;�;�;�I�I�I�Y�Y�Y�S�S�S������X���!�!�!��X�!������X���\����\���!�!��X�!���	/�	/���	/��!�!��X�!��������6����X���\�
-�
-��\�
-�����X���]�	*�	*��]�	*�����X����-�-���-�����X����-�-���-��%�%��X�%���$�$���$��%�%��X�%���$�$���$�����X���]����]������X���\����\������X���\����\������X��	�Z����Z������X���]����]���!�!��X�!��� � ��� �����X���_����_������X���]����]���"�"��X�"���!�!���!�����X���]����]���.�.��X�.��$�-�-�%�$�-�����X���]����]������X���]����]��� � ��X� ���.�.���.��"�"��X�"���0�0���0��#�#��X�#�������� �#�#��X�#���"�"���"��(�(��X�(���'�'���'��)�)��X�)���(�(� ��(��#�#��X�#���"�"���"�
�%�%��X�%���$�$���$�
�E�E��X�E��!�*�*�"�!�*�
�#�#��X�#���"�"���"�
�=�=��X�=���&�&���&�
�@�@��X�@�� �)�)�!� �)�
�?�?��X�?���(�(� ��(�
�>�>��X�>���'�'���'�
�C�C��X�C��#�,�,�$�#�,�
�B�B��X�B��"�+�+�#�"�+�
�F�F��X�F� �&�/�/�'�&�/�
�E�E��X�E��%�.�.�&�%�.�
����X���]����]���!�!��X�!��� � ��� �� � ��X� ���������"�"��X�"���!�!���!����6�6�6�6�(���	*�	*�	*�/�/�/�*!�!�!�%�%�%�/�/�/�/�/�/�E�E�E�"����',�'�'�'�'�'�'�$
&�
&�
&�
&� BE������@!�!�!�!�!�����&��������#�#�#�
�
�
�
�
�4'�'�'����@&�@&�@&�D	�	�	����:���"
�
�
�7�7�7�k �k �k �k �Z%�%�%�%�N � � �.@�@�@�DV�V�V�p
&�
&�
&�
&�
&�%�%�%�%�63�3�3�3�8(�(�(�(�T0 �0 �0 �dU �U �U �v����@"�"�"�B4"�4"�4"�4"�4"rr(c�\�tjt�d|����S)Nr�)�wcwidth�wcswidth�_re�sub)r�s rrr^	s!����C�G�G�B��,�,�-�-�-rrd�
Any | Nonec���i}dD]}||vr|�|��||<�|rtj|fi|��}nctj���|�d����}|�d��tj||��}tdi|��}|r||_nd�t|��D��|_|D]!}|�
d�|D�����"|S)N)�	delimiter�doublequote�
escapechar�lineterminator�	quotechar�quoting�skipinitialspace�strictirc�6�g|]}|�����SrZ��striprs  rrzfrom_csv.<locals>.<listcomp>�	s ��=�=�=�1�Q�W�W�Y�Y�=�=�=rc�6�g|]}|�����SrZr�rs  rrzfrom_csv.<locals>.<listcomp>�	s ��.�.�.�Q�q�w�w�y�y�.�.�.rrZ)rr��reader�Sniffer�sniff�read�seekr(rd�nextr�)	�fprdr��	fmtparams�paramr��dialect�tabler�s	         r�from_csvr�g	s���I�	�1�1���F�?�?�%�z�z�%�0�0�I�e����)���B�,�,�)�,�,����+�-�-�%�%�b�g�g�d�m�m�4�4��
����
�
�
���B��(�(���!�!�&�!�!�E��>�'����=�=��V���=�=�=����0�0��
�
�
�.�.�#�.�.�.�/�/�/�/��Lrc��|jrPtdi|��}d�|jD��|_|���D]}|�|���|SdS)Nc��g|]
}|d��Sr�rZ)r�cols  rrz"from_db_cursor.<locals>.<listcomp>�	s��B�B�B��S��V�B�B�BrrZ)�descriptionr(rd�fetchallr�)�cursorr�r�r�s    r�from_db_cursorr��	sv��
����%�%�f�%�%��B�B�v�/A�B�B�B����?�?�$�$�	�	�C��M�M�#��������rc����tdi|��}tj|��}|d|_|dd�D]*��fd�|jD��}|�|���+|S)Nrrc� ��g|]
}�|��SrZrZ)rr��objs  �rrzfrom_json.<locals>.<listcomp>�	s���5�5�5�C�s�3�x�5�5�5rrZ)r(r��loadsrdr�)�json_stringr�r�r@r�r�s     @r�	from_jsonr��	s~����!�!�&�!�!�E��j��%�%�G���
�E���q�r�r�{����5�5�5�5�5�#4�5�5�5��
�
�
�c������Lrc�<�eZdZd
d�Zd
d�Zd
d�Zd
d�Zd�Zd
d�Zd	S)�TableHandlerr)r*c��tj|��||_g|_g|_g|_d|_d|_d|_d|_	d|_
dS)Nrr�F)rr�r��tables�last_rowr�
max_row_width�active�last_content�is_last_row_header�colspan)r�r�s  rr�zTableHandler.__init__�	sY����D�!�!�!����"$���#%��
�!��	����������"'�������rc�r�||_|dkrd|_|D]\}}|dkrt|��|_� dS)N�thTr�)r�r�r�r�)r��tag�attrsr�r�s     r�handle_starttagzTableHandler.handle_starttag�	sP������$�;�;�&*�D�#��	*�	*�J�C���i���"�5�z�z����	*�	*rc�^�|dvrs|j���}|j�|��|jr9td|j��D]}|j�d���d|_|dkr`|j�|j|jf��t|j	t|j����|_	g|_d|_|dkr;|�|j��}|j�|��g|_d|_d|_
dS)	N)r��tdrr�r�trFr�r�)r�r�r�r�r�r�rr�r!r�r �generate_tabler�r�)r�r��stripped_contentr�r�s     r�
handle_endtagzTableHandler.handle_endtag�	s#���,���#�0�6�6�8�8���M� � �!1�2�2�2��|�
!��q�$�,�/�/�-�-�A��M�(�(��,�,�,�,� ����$�;�;��I���d�m�T�-D�E�F�F�F�!$�T�%7��T�]�9K�9K�!L�!L�D���D�M�&+�D�#��'�>�>��'�'��	�2�2�E��K���u�%�%�%��D�I��������rc�&�|xj|z
c_dSr)r�)r��datas  r�handle_datazTableHandler.handle_data�	s�����T�!����rc��tdi|j��}|jD]�}t|d��|jkrK|jt|d��z
}td|��D]}|d�d���|dr)|�|d��|d|_��|�	|d����|S)zE
        Generates from a list of rows a PrettyTable object.
        rrr^rZ)
r(r�rr r�r�r��make_fields_uniquerdr�)r�rr�r��appendsr�s      rr�zTableHandler.generate_table�	s����*�*�d�k�*�*���9�
	&�
	&�C��3�q�6�{�{�T�/�/�/��,�s�3�q�6�{�{�:���q�'�*�*�'�'�A���F�M�M�#�&�&�&�&��1�v�
&��'�'��A��/�/�/�$'��F��!�!��
�
�c�!�f�%�%�%�%��rc���tdt|����D]G}t|dzt|����D]$}||||kr||xxdz
cc<�%�HdS)zB
        iterates over the row and make each field unique
        rr�'N)r�r )r�r0r��js    rr�zTableHandler.make_fields_unique�	s���q�#�f�+�+�&�&�	%�	%�A��1�q�5�#�f�+�+�.�.�
%�
%���!�9��q�	�)�)��1�I�I�I��$�I�I�I��
%�	%�	%rNr�)	r�r�r�r�r�r�r�r�r�rZrrr�r��	s�������
�
�
�
�*�*�*�*�����*"�"�"�"����$%�%�%�%�%�%rr�c�R�tdi|��}|�|��|jS)z�
    Generates a list of PrettyTables from a string of HTML code. Each <table> in
    the HTML becomes one PrettyTable object.
    rZ)r��feedr�)�	html_coder��parsers   r�	from_htmlr��	s1���
#�
#�F�
#�
#�F�
�K�K�	�����=�rc��t|fi|��}	t|��dksJ�n#t$rtd���wxYw|dS)zf
    Generates a PrettyTables from a string of HTML code which contains only a
    single <table>
    rzCMore than one <table> in provided HTML code. Use from_html instead.r)r�r r�r�)r�r�r�s   r�
from_html_oner��	st���y�
+�
+�F�
+�
+�F�
��6�{�{�a��������
�
�
��Q�
�
�	
�
�����!�9�s�%�?r)rdr�))�
__future__rr�r�r.r�r�r��rerr�r�html.parserr�typingrr�rqrsr�r�r�r�r�r�r�r�r�r�r�compiler�r&r(rr�r�r�r�r�r�rZrr�<module>r�s���D#�"�"�"�"�"�����
�
�
�
�	�	�	�	���������
�
�
�
�	�	�	�	�����������"�"�"�"�"�"�����������	
������	
��
�����
�
��
���
��
�	��%���b�j�*�+�+�����I$"�I$"�I$"�I$"�I$"�I$"�I$"�I$"�bH.�.�.������B������F%�F%�F%�F%�F%�:�F%�F%�F%�R���
�
�
�
�
r

Hacked By AnonymousFox1.0, Coded By AnonymousFox