shell bypass 403

Cubjrnet7 Shell


name : prettytable.cpython-39.opt-1.pyc
a

F�`Q���@s`dZddlZddlZddlZddlZddlZddlZddlZddlZej	ddkZ
e
rxeZeZ
eZeZeZddlmZnejZejZeZddlmZe
r�ej	ddkr�ddlmZnddlmZdZdZdZdZdZ d	Z!d
Z"dZ#e�$d�Z%d
d�Z&Gdd�de'�Z(dd�Z)dd�Z*d"dd�Z+dd�Z,Gdd�de�Z-dd�Z.dd�Z/dd �Z0e1d!k�r\e0�dS)#z0.7.2�N�)�
HTMLParser��)�escape�
���z\[[0-9;]*mcCs,|�d�}t|�}tdd�|D��}||fS)N�
cSsg|]}t|��qS���_str_block_width)�.0�linerr�//usr/lib/python3.9/site-packages/prettytable.py�
<listcomp>O�z_get_size.<locals>.<listcomp>)�split�len�max)�text�linesZheight�widthrrr�	_get_sizeLs
rc@sBeZdZd�dd�Zdd�Zdd�Zdd	�Zd
d�Zer@dd
�Z	ndd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zeee�Zd5d6�Zd7d8�Z eee �Z!d9d:�Z"d;d<�Z#ee"e#�Z$d=d>�Z%d?d@�Z&ee%e&�Z'dAdB�Z(dCdD�Z)ee(e)�Z*dEdF�Z+dGdH�Z,ee+e,�Z-dIdJ�Z.dKdL�Z/ee.e/�Z0dMdN�Z1dOdP�Z2ee1e2�Z3dQdR�Z4dSdT�Z5ee4e5�Z6dUdV�Z7dWdX�Z8ee7e8�Z9dYdZ�Z:d[d\�Z;ee:e;�Z<d]d^�Z=d_d`�Z>ee=e>�Z?dadb�Z@dcdd�ZAee@eA�ZBdedf�ZCdgdh�ZDeeCeD�ZEdidj�ZFdkdl�ZGeeFeG�ZHdmdn�ZIdodp�ZJeeIeJ�ZKdqdr�ZLdsdt�ZMeeLeM�ZNdudv�ZOdwdx�ZPeeOeP�ZQdydz�ZRd{d|�ZSeeReS�ZTd}d~�ZUdd��ZVeeUeV�ZWd�d��ZXd�d��ZYeeXeY�ZZd�d��Z[d�d��Z\ee[e\�Z]d�d��Z^d�d��Z_ee^e_�Z`d�d��Zad�d��Zbeeaeb�Zcd�d��Zdd�d��Zeeedee�Zfd�d��Zgd�d��Zheegeh�Zid�d��Zjd�d��Zkd�d��Zld�d��Zmd�d��Znd�d��Zod�d��Zpd�d��Zqd�d�d��Zrd�d��Zsd�d��Ztd�d��Zud�d��Zvd�d��Zwd�d��Zxd�d��Zyd�d��Zzd�d��Z{d�d��Z|d�d„Z}d�dĄZ~d�dƄZd�dȄZ�d�dʄZ�d�d̄Z�dS)��PrettyTableNcKsV|�dd�|_g|_i|_i|_i|_g|_|r8||_ng|_d�	�|_
|j
�d�	��|j
�d�	��|j
D]&}||vr�|�|||�qnd||<qn|dp�d|_
|d	p�d|_|d
p�d|_|ddvr�|d|_nd
|_|dp�d|_|ddv�r|d|_nd
|_|d�pt|_|d�p(t|_|d�p8d|_|ddv�rV|d|_nd|_|d�pldd�|_|d�p|i|_|d�p�i|_|d�p�d|_|d�p�d|_|d�p�d|_|d�p�|�d�|_ |d �p�|�d!�|_!|d"�p�|�d#�|_"|d$dv�r|d$|_#nd
|_#|d%�p.d|_$|d&�p>d|_%|d'�pNi|_&dS)(a�Return a new PrettyTable instance

        Arguments:

        encoding - Unicode encoding scheme used to decode any encoded input
        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)
        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
        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
        junction_char - single character string used to draw line junctions
        sortby - name of field to sort rows by
        sort_key - sorting key function, applied to data points before sorting
        valign - default valign for each row (None, "t", "m" or "b")
        reversesort - True or False to sort in descending or ascending order�encodingzUTF-8zZstart end fields header border sortby reversesort sort_key attributes format hrules vruleszLint_format float_format padding_width left_padding_width right_padding_widthzQvertical_char horizontal_char junction_char header_style valign xhtml print_emptyN�startr�end�fields�header�TFT�header_style�border�hrules�vrules�sortby�reversesortF�sort_keycSs|S�Nr��xrrr�<lambda>�rz&PrettyTable.__init__.<locals>.<lambda>�
int_format�float_format�
padding_widthr�left_padding_width�right_padding_width�
vertical_char�|�horizontal_char�-�
junction_char�+�print_empty�format�xhtml�
attributes)'�getr�_field_names�_align�_valign�
_max_width�_rows�field_names�_widthsr�_options�extend�_validate_option�_start�_end�_fields�_header�
_header_style�_border�FRAME�_hrules�ALL�_vrules�_sortby�_reversesort�	_sort_key�_int_format�
_float_format�_padding_width�_left_padding_width�_right_padding_width�_unicode�_vertical_char�_horizontal_char�_junction_char�_print_empty�_formatZ_xhtml�_attributes)�selfrB�kwargs�optionrrr�__init__Ts^


zPrettyTable.__init__cCs.t|t�st|�}t|t�s*t||jd�}|S)N�strict)�
isinstance�
basestring�str�unicoder)r`�valuerrrrY�s


zPrettyTable._unicodecCs�|t|�}|dkr ||dS|dkr4|d|S|dr�t|�drh|dd||dddS|ddd||ddSn|dd||ddSdS)N�l� �rrrr
)r`rr�alignZexcessrrr�_justify�s "zPrettyTable._justifycCsP|dkrt|j�S|dkrD|jr*t|j�S|jr>t|jd�SdSnt|��dS)N�rowcountZcolcountr)rrAr=�AttributeError)r`�namerrr�__getattr__�s

zPrettyTable.__getattr__cCs�t�}|j|_|jD]}t|d|t|d|��qt|dt|d��t|t�rl|j|D]}|�|�qZn,t|t	�r�|�|j|�nt
dt|���|S)N�_r>z0Index %s is invalid, must be an integer or slice)rrBrD�setattr�getattrre�slicerA�add_row�int�	Exceptionrg)r`�index�new�attr�rowrrr�__getitem__�s


zPrettyTable.__getitem__cCs|��Sr))�__unicode__�r`rrr�__str__�szPrettyTable.__str__cCs|���|j�Sr))r�encoderr�rrrr��scCs|��Sr))�
get_stringr�rrrr�szPrettyTable.__unicode__cCs2|dvr|�|��n|dvr.|�||��n|dvrD|�||�n�|dvrZ|�||�n�|dvrp|�||�n�|dvr�|�||�n�|dvr�|�||�n�|dvr�|�||�n||d	vr�|�|�nh|d
vr�|�	||�nR|dvr�|�
||�n<|dv�r
|�||�n$|d
v�r"|�||�nt
d|��dS)NrB)rr�	max_widthr/r0r1r9r&r(r$r%r)r r#r'r:r8r"r-r.)r2r4r6r;zUnrecognised option: %s!)�_validate_field_names�_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�_validate_single_char�_validate_attributesry)r`rb�valrrrrFs6

zPrettyTable._validate_optionc	Cs�|jr8zWn,ty6tdt|�t|j�f��Yn0|jrtzWn0tyrtdt|�t|jd�f��Yn0zWnty�td��Yn0dS)NzJField name list has incorrect number of values, (actual) %d!=%d (expected)rzField names must be unique!)r=�AssertionErrorryrrA�r`r�rrrr�s $z!PrettyTable._validate_field_namescCs$zWntytd��Yn0dS)Nz;Invalid header style, use cap, title, upper, lower or None!�r�ryr�rrrr�0sz"PrettyTable._validate_header_stylecCs(zWnty"td|��Yn0dS)Nz'Alignment %s is invalid, use l, c or r!r�r�rrr�_validate_align6szPrettyTable._validate_aligncCs(zWnty"td|��Yn0dS)Nz-Alignment %s is invalid, use t, m, b or None!r�r�rrr�_validate_valign<szPrettyTable._validate_valignc	Cs2zWn(ty,td||�|�f��Yn0dS)NzInvalid value for %s: %s!)r�ryrY�r`rqr�rrrr�Bsz%PrettyTable._validate_nonnegative_intcCs(zWnty"td|��Yn0dS)Nz-Invalid value for %s!  Must be True or False.r�r�rrrr�Hsz#PrettyTable._validate_true_or_falsecCs4|dkrdSzWnty.td|��Yn0dS)N�z8Invalid value for %s!  Must be an integer format string.r�r�rrrr�Nsz PrettyTable._validate_int_formatcCs>|dkrdSz|�d�}Wnty8td|��Yn0dS)Nr��.z5Invalid value for %s!  Must be a float format string.)rr�ry)r`rqr��bitsrrrr�Ws
z"PrettyTable._validate_float_formatcCs(zWnty"td|��Yn0dS)Nz*Invalid value for %s!  Must be a function.r�r�rrrr�dszPrettyTable._validate_functioncCs(zWnty"td|��Yn0dS)Nz:Invalid value for %s!  Must be ALL, FRAME, HEADER or NONE.r�r�rrrr�jszPrettyTable._validate_hrulescCs(zWnty"td|��Yn0dS)Nz3Invalid value for %s!  Must be ALL, FRAME, or NONE.r�r�rrrr�pszPrettyTable._validate_vrulescCs(zWnty"td|��Yn0dS)NzInvalid field name: %s!r�r�rrrr�vsz PrettyTable._validate_field_namecCs:z|D]}|�||�qWnty4td��Yn0dS)Nz)fields must be a sequence of field names!)r�r�ry)r`rqr�r+rrrr�|s
z%PrettyTable._validate_all_field_namescCs(zWnty"td|��Yn0dS)Nz4Invalid value for %s!  Must be a string of length 1.r�r�rrrr��sz!PrettyTable._validate_single_charcCs$zWntytd��Yn0dS)Nz4attributes must be a dictionary of name/value pairs!r�r�rrrr��sz PrettyTable._validate_attributescCs|jSr))r=r�rrr�_get_field_names�szPrettyTable._get_field_namescs�fdd�|D�}��d|��jr2�jdd�}|�_�jr�|r�t||�D]\}}�j|�j|<qL|D]}|�jvrj�j�|�qjn�jD]}d�j|<q��jr�|r�t||�D]\}}�j|�j|<q�|D]}|�jvrЈj�|�q�n�jD]}d�j|<q�dS)Ncsg|]}��|��qSr)rY�rr+r�rrr�rz0PrettyTable._set_field_names.<locals>.<listcomp>rB�c�t)rFr=r>�zip�popr?)r`r�Z	old_namesZold_name�new_name�fieldrr�r�_set_field_names�s*





zPrettyTable._set_field_namescCs|jSr))r>r�rrr�
_get_align�szPrettyTable._get_aligncCs$|�|�|jD]}||j|<qdSr))r�r=r>�r`r�r�rrr�
_set_align�s

zPrettyTable._set_aligncCs|jSr))r?r�rrr�_get_valign�szPrettyTable._get_valigncCs$|�|�|jD]}||j|<qdSr))r�r=r?r�rrr�_set_valign�s

zPrettyTable._set_valigncCs|jSr))r@r�rrr�_get_max_width�szPrettyTable._get_max_widthcCs&|�d|�|jD]}||j|<qdS)Nr�)rFr=r@r�rrr�_set_max_width�s
zPrettyTable._set_max_widthcCs|jS)z�List or tuple of field names to include in displays

        Arguments:

        fields - list or tuple of field names to include in displays)rIr�rrr�_get_fields�szPrettyTable._get_fieldscCs|�d|�||_dS)Nr)rFrIr�rrr�_set_fields�szPrettyTable._set_fieldscCs|jS)z{Start index of the range of rows to print

        Arguments:

        start - index of first data row to include in output)rGr�rrr�
_get_start�szPrettyTable._get_startcCs|�d|�||_dS)Nr)rFrGr�rrr�
_set_start�szPrettyTable._set_startcCs|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))rHr�rrr�_get_end�szPrettyTable._get_endcCs|�d|�||_dS)Nr)rFrHr�rrr�_set_end�szPrettyTable._set_endcCs|jS)z_Name of field by which to sort rows

        Arguments:

        sortby - field name to sort by)rQr�rrr�_get_sortby�szPrettyTable._get_sortbycCs|�d|�||_dS)Nr&)rFrQr�rrr�_set_sortby�szPrettyTable._set_sortbycCs|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)rRr�rrr�_get_reversesort�szPrettyTable._get_reversesortcCs|�d|�||_dS)Nr')rFrRr�rrr�_set_reversesortszPrettyTable._set_reversesortcCs|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)rSr�rrr�
_get_sort_key	szPrettyTable._get_sort_keycCs|�d|�||_dS)Nr()rFrSr�rrr�
_set_sort_keyszPrettyTable._set_sort_keycCs|jS)z�Controls printing of table header with field names

        Arguments:

        header - print a header showing field names (True or False))rJr�rrr�_get_headerszPrettyTable._get_headercCs|�d|�||_dS)Nr )rFrJr�rrr�_set_headerszPrettyTable._set_headercCs|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))rKr�rrr�_get_header_style!szPrettyTable._get_header_stylecCs|�|�||_dSr))r�rKr�rrr�_set_header_style(s
zPrettyTable._set_header_stylecCs|jS)z~Controls printing of border around table

        Arguments:

        border - print a border around the table (True or False))rLr�rrr�_get_border-szPrettyTable._get_bordercCs|�d|�||_dS)Nr#)rFrLr�rrr�_set_border4szPrettyTable._set_bordercCs|jS)z�Controls printing of horizontal rules after rows

        Arguments:

        hrules - horizontal rules style.  Allowed values: FRAME, ALL, HEADER, NONE)rNr�rrr�_get_hrules9szPrettyTable._get_hrulescCs|�d|�||_dS)Nr$)rFrNr�rrr�_set_hrules@szPrettyTable._set_hrulescCs|jS)z�Controls printing of vertical rules between columns

        Arguments:

        vrules - vertical rules style.  Allowed values: FRAME, ALL, NONE)rPr�rrr�_get_vrulesEszPrettyTable._get_vrulescCs|�d|�||_dS)Nr%)rFrPr�rrr�_set_vrulesLszPrettyTable._set_vrulescCs|jS)zbControls formatting of integer data
        Arguments:

        int_format - integer format string)rTr�rrr�_get_int_formatQszPrettyTable._get_int_formatcCs|jD]}||j|<qdSr))r=rTr�rrr�_set_int_formatWs
zPrettyTable._set_int_formatcCs|jS)zrControls formatting of floating point data
        Arguments:

        float_format - floating point format string)rUr�rrr�_get_float_format]szPrettyTable._get_float_formatcCs|jD]}||j|<qdSr))r=rUr�rrr�_set_float_formatcs
zPrettyTable._set_float_formatcCs|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)rVr�rrr�_get_padding_widthiszPrettyTable._get_padding_widthcCs|�d|�||_dS)Nr/)rFrVr�rrr�_set_padding_widthpszPrettyTable._set_padding_widthcCs|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)rWr�rrr�_get_left_padding_widthusz#PrettyTable._get_left_padding_widthcCs|�d|�||_dS)Nr0)rFrWr�rrr�_set_left_padding_width|sz#PrettyTable._set_left_padding_widthcCs|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)rXr�rrr�_get_right_padding_width�sz$PrettyTable._get_right_padding_widthcCs|�d|�||_dS)Nr1)rFrXr�rrr�_set_right_padding_width�sz$PrettyTable._set_right_padding_widthcCs|jS)z�The charcter used when printing table borders to draw vertical lines

        Arguments:

        vertical_char - single character string used to draw vertical lines)rZr�rrr�_get_vertical_char�szPrettyTable._get_vertical_charcCs |�|�}|�d|�||_dS�Nr2)rYrFrZr�rrr�_set_vertical_char�s
zPrettyTable._set_vertical_charcCs|jS)z�The charcter used when printing table borders to draw horizontal lines

        Arguments:

        horizontal_char - single character string used to draw horizontal lines)r[r�rrr�_get_horizontal_char�sz PrettyTable._get_horizontal_charcCs |�|�}|�d|�||_dS)Nr4)rYrFr[r�rrr�_set_horizontal_char�s
z PrettyTable._set_horizontal_charcCs|jS)z�The charcter used when printing table borders to draw line junctions

        Arguments:

        junction_char - single character string used to draw line junctions)r\r�rrr�_get_junction_char�szPrettyTable._get_junction_charcCs |�|�}|�d|�||_dSr�)rYrFr\r�rrr�_set_junction_char�s
zPrettyTable._set_junction_charcCs|jS)z~Controls whether or not HTML tables are formatted to match styling options

        Arguments:

        format - True or False)r^r�rrr�_get_format�szPrettyTable._get_formatcCs|�d|�||_dS)Nr9)rFr^r�rrr�_set_format�szPrettyTable._set_formatcCs|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�rrr�_get_print_empty�szPrettyTable._get_print_emptycCs|�d|�||_dS)Nr8)rFr]r�rrr�_set_print_empty�szPrettyTable._set_print_emptycCs|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�rrr�_get_attributes�szPrettyTable._get_attributescCs|�d|�||_dS)Nr;)rFr_r�rrr�_set_attributes�szPrettyTable._set_attributescCsLi}|jD]<}||vr4|�|||�||||<q
t|d|�||<q
|S)Nrs)rDrFru)r`ra�optionsrbrrr�_get_options�s
zPrettyTable._get_optionscCsT|tkr|��n>|tkr$|��n,|tkr6|��n|tkrH|��ntd��dS)NzInvalid pre-set style!)	�DEFAULT�_set_default_style�MSWORD_FRIENDLY�_set_msword_style�
PLAIN_COLUMNS�_set_columns_style�RANDOM�_set_random_stylery)r`Zstylerrr�	set_style�s



zPrettyTable.set_stylecCs@d|_d|_t|_t|_d|_d|_d|_d|_	d|_
d|_dS)NTrr3r5r7)r r#rMrNrOrPr/r0r1r2r4r6r�rrrr��szPrettyTable._set_default_stylecCs.d|_d|_t|_d|_d|_d|_d|_dS)NTrr3)r r#�NONErNr/r0r1r2r�rrrr�szPrettyTable._set_msword_stylecCs"d|_d|_d|_d|_d|_dS)NTFrr�)r r#r/r0r1r�rrrr�s
zPrettyTable._set_columns_stylecCs�t�d�|_t�d�|_t�ttttf�|_t�tttf�|_	t�
dd�|_t�
dd�|_t�d�|_
t�d�|_t�d�|_dS)Nr!r�z ~!@#$%^&*()_+|-=\{}[];':",./;<>?)�random�choicer r#rOrM�HEADERr�rNrPZrandintr0r1r2r4r6r�rrrr�szPrettyTable._set_random_stylecCsf|jr2t|�t|j�kr2tdt|�t|j�f��|jsRdd�tdt|��D�|_|j�t|��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) %d!=%d (expected)cSsg|]}d|d�qS)zField %drr)r�nrrrr4rz'PrettyTable.add_row.<locals>.<listcomp>rN)r=rry�rangerBrA�append�list)r`r}rrrrw(s
	zPrettyTable.add_rowcCs4|t|j�dkr(td|t|j�f��|j|=dS)z�Delete a row to the table

        Arguments:

        row_index - The index of the row you want to delete.  Indexing starts at 0.rz4Cant delete row at index %d, table only has %d rows!N)rrAry)r`Z	row_indexrrr�del_row7szPrettyTable.del_rowr�r�cCs�t|j�dt|�fvr�|�|�|�|�|j�|�||j|<||j|<tdt|��D]6}t|j�|dkrz|j�g�|j|�||�qXnt	dt|�t|j�f��dS)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 bottomrrz2Column length %d does not match number of rows %d!N)
rrAr�r�r=r�r>r?r�ry)r`�	fieldname�columnrm�valign�irrr�
add_columnCs



zPrettyTable.add_columncCs
g|_dS)z?Delete all rows from the table but keep the current field namesN)rAr�rrr�
clear_rows\szPrettyTable.clear_rowscCsg|_g|_g|_dS)zWDelete all rows and field names from the table, maintaining nothing but styling optionsN)rAr=rCr�rrr�clearbszPrettyTable.clearcCs
t�|�Sr))�copy�deepcopyr�rrrr�nszPrettyTable.copycCsdt|t�r.||jvr.|�d|j||�}n,t|t�rZ||jvrZ|�d|j||�}|�|�S)Nz%%%sdz%%%sf)rerxrTrY�floatrU)r`r�rirrr�
_format_valueus
zPrettyTable._format_valuecCs�|drdd�|jD�}nt|j�dg}|D]l}t|�D]^\}}|j|}||jvr~t||tt|�d|j|��||<q:t||t|�d�||<q:q.||_dS)Nr cSsg|]}t|�d�qS�r)r)rr�rrrr~rz/PrettyTable._compute_widths.<locals>.<listcomp>r)	r=rrB�	enumerater�r�minrrC)r`�rowsr�Zwidthsr}rzrir�rrr�_compute_widths|s

(zPrettyTable._compute_widthscCsD|ddur|d}n|d}|ddur4|d}n|d}||fS)Nr0r/r1r)r`r��lpad�rpadrrr�_get_padding_widths�s

zPrettyTable._get_padding_widthscsnt�|j|d|d��}|drj|j�|d���fdd�|D�}|j|d|dd�d	d�|D�}|S)
z�Return only those data rows that should be printed, based on slicing and sorting.

        Arguments:

        options - dictionary of option settings.rrr&csg|]}|�g|�qSrr�rr}�Z	sortindexrrr�rz)PrettyTable._get_rows.<locals>.<listcomp>r'r()�reverse�keycSsg|]}|dd��qS)rNrrrrrr�r)r�r�rAr=rz�sort)r`r�r�rrr�	_get_rows�szPrettyTable._get_rowscs�fdd�t�j|�D�S)Ncsg|]\}}��||��qSr)r�)rr�rir�rrr�rz+PrettyTable._format_row.<locals>.<listcomp>)r�r=)r`r}r�rr�r�_format_row�szPrettyTable._format_rowcs��fdd�|D�S)Ncsg|]}��|���qSr)rr�r�r`rrr�rz,PrettyTable._format_rows.<locals>.<listcomp>r)r`r�r�rr	r�_format_rows�szPrettyTable._format_rowscKs�|�|�}g}|jdkr,|dr(|ds,dS|�|�}|�||�}|�||�|�|�|_|drt|�|�|��n$|dr�|dt	t
fvr�|�|j�|D]}|�|�||��q�|dr�|dt
kr�|�|j�|�d��
|�S)a"Return string representation 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)
        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
        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
        junction_char - single character string used to draw 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 string rr8r#r�r r$r)r�rorr
r��_stringify_hrule�_hruler��_stringify_headerrOrM�_stringify_rowrY�join)r`rar�rr��formatted_rowsr}rrrr��s"

zPrettyTable.get_stringcCs�|dsdS|�|�\}}|dttfvr6|dg}n
|dg}|js^|�|d�d�|�St|j|j�D]b\}}|dr�||dvr�ql|�||||d�|dtkr�|�|d�ql|�|d�ql|dtkr�|��|�|d�d�|�S)Nr#r�r%r6r4r)	rrOrMr=r�rr�rCr�)r`r�r�rr�r�rrrrr�s(

zPrettyTable._stringify_hrulec
Cs�g}|�|�\}}|drj|dttfvr@|�|j�|�d�|dttfvr`|�|d�n
|�d�|js�|dttfvr�|�|d�n
|�d�t|j|j�D]�\}}|dr�||dvr�q�|jdkr�|�	�}nD|jd	kr�|�
�}n0|jd
k�r|��}n|jdk�r|��}n|}|�d||�
|||j|�d|�|dr�|dtk�rn|�|d�q�|�d�q�|d�r�|dtk�r�|��|�|d�|d�r�|dtk�r�|�d�|�|j�d�|�S)
Nr#r$rr%r2rkrZcap�title�upper�lowerr�)rrOrMr�rr=r�rCrK�
capitalizerrrrnr>r�r�r)r`r�r�r�rr�rr�rrrr
sJ








*
zPrettyTable._stringify_headercCs�ttdt|��|j||j�D]\\}}}}|�d�}g}|D]&}	t|	�|krVt�|	|�}	|�	|	�q:|}d�
|�}|||<qd}
|D]}t|�d}||
kr�|}
q�g}
|�|�\}}td|
�D]F}|
�	g�|dr�|dt
tfvr�|
|�	|j�q�|
|�	d�q�t|j||j�D�],\}}}|j|}|�d�}|
t|�}|�r�|dk�r~dgt|d	�|dg|t|d	�}n(|d
k�r�dg||}n|dg|}d}|D]�}|d�r�||dv�rΐq�|
|�	d||�|||j|�d|�|d�r4|dt
k�r&|
|�	|j�n|
|�	d�|d7}�q��qtd|
�D]<}|d�rN|dtk�rN|
|��|
|�	|d��qN|d�r�|d
t
k�r�|
|
d�	d�|
|
d�	|j�td|
�D]}d�
|
|�|
|<�q�d�
|
�S)Nrrrr#r%rk�mr�r�brr2r$)r�r�rr=rCrr�textwrap�fillr�rrrrOrMr2r?rxrnr>r�r)r`r}r�rzr�rirrZ	new_linesrZ
row_heightr��hr�r�r�yr�ZdHeightrjrrrr:sj(






.
.
zPrettyTable._stringify_rowcKs,|�|�}|dr|�|�}n
|�|�}|S)a;Return string representation of HTML 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)
        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
        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
        xhtml - print <br/> tags if True, <br> tags if falser9)r��_get_formatted_html_string�_get_simple_html_string)r`rar��stringrrr�get_html_string�s


zPrettyTable.get_html_stringc	Cs^g}|drd}nd}g}|�d�|drT|dD]}|�d||d|f�q4|�d�|�d�|��|d	r�|�d
�|jD]4}|dr�||dvr�q�|�dt|��d
|��q�|�d�|�|�}|�||�}|D]b}	|�d
�t|j|	�D]<\}}
|d�r||dv�rq�|�dt|
��d
|��q�|�d�q�|�d�|�d
��|�S)Nr:�<br/>�<br>�<tabler;� %s="%s"�>r�r �    <tr>rz        <th>%s</th>r�	    </tr>z        <td>%s</td>�</table>)	r�rr=r�replacerr
r�rY)r`r�r�	linebreak�open_tag�	attr_namer�r�rr}�datumrrrr�s:







z#PrettyTable._get_simple_html_stringc
Cs�g}|�|�\}}|dr d}nd}g}|�d�|d�r|dtkr`|dtkr`|�d�n�|dtkr�|dtkr�|�d	�n�|dtkr�|dtkr�|�d
�n`|dtkr�|�d�nH|dtkr�|�d�n0|dtkr�|�d
�n|dtk�r|�d�|d�r<|dD] }|�d||d|f��q|�d�|�d�|��|d�r�|�d�|jD]B}|d�r�||dv�r��qp|�d||t|��d|�f��qp|�d�|�|�}	|�	|	|�}
g}g}|jD]>}|�dddd�|j
|�|�dddd �|j|��q�|
D]z}
|�d�t|j|
||�D]N\}}}}|d�rl||dv�rl�qD|�d!||||t|��d|�f��qD|�d��q&|�d"�|�
d��|�S)#Nr:rr r!r#r$r%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"r;r"r#r�r r$rzW        <th style="padding-left: %dem; padding-right: %dem; text-align: center">%s</th>rr%�left�right�center)rjrlr��topZmiddleZbottom)r�rrzg        <td style="padding-left: %dem; padding-right: %dem; text-align: %s; vertical-align: %s">%s</td>r&)rr�rOrMrr=rr'rr
r>r?r�rY)r`r�rr�rr(r)r*r�r�rZalignsZvalignsr}r+rmr�rrrr�sd







$


 
(
z&PrettyTable._get_formatted_html_string)N)r�r�)��__name__�
__module__�__qualname__rcrYrnrrr~�py3kr�rrFr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r��propertyrBr�r�rmr�r�r�r�r�r�r�r�rr�r�rr�r�rr�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�r-r�r�r.r�r�r/r�r�r0r�r�r1r�r�r2r�r�r4r�r�r6r�r�r9r�r�r8r�r�r;r�r�r�r�r�r�rwr�r�r�r�r�r�r�rrrr
r�rr
rrrrrrrrrRs
]
	































=/L (rcCs�d|krdkrnndSd|kr0dkr8nndSd|krLdkrTnndSt�t|��rfd	Sd
|krzdks�nd|kr�d
kr�nndSd|kr�dkr�nndSd|kr�dkr�nndS|dvr�dS|dvr�d	SdS)N�!�~riNi��ri�i��ri@0i�0i�0i�0i�i`�i0i>0)r�����)r�)�unicodedataZ	combining�uni_chr)�charrrr�_char_block_widths&.r=c	Cstttttt�d|����S)Nr�)�sum�itermapr=�ord�_re�sub)r�rrrr/srcKs�t���|�d��}|�d�t�||�}tfi|��}|rD||_n.tr^dd�t	|�D�|_ndd�|�	�D�|_|D]}|�
dd�|D��qv|S)NircSsg|]}|���qSr��stripr�rrrrBrzfrom_csv.<locals>.<listcomp>cSsg|]}|���qSrrCr�rrrrDrcSsg|]}|���qSrrCr�rrrrGr)�csvZSnifferZsniff�read�seek�readerrrBr3�nextrw)�fprBraZdialectrH�tabler}rrr�from_csv7s
rLcKsF|jrBtfi|��}dd�|jD�|_|��D]}|�|�q.|SdS)NcSsg|]}|d�qSr�r)r�colrrrrOrz"from_db_cursor.<locals>.<listcomp>)�descriptionrrBZfetchallrw)ZcursorrarKr}rrr�from_db_cursorKsrOc@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�TableHandlercKs>t�|�||_g|_g|_g|_d|_d|_d|_d|_	dS)Nrr�F)
rrcra�tables�last_rowr��
max_row_width�active�last_content�is_last_row_header)r`rarrrrcVs
zTableHandler.__init__cCs||_|dkrd|_dS)N�thT)rTrV)r`�tag�attrsrrr�handle_starttagaszTableHandler.handle_starttagcCs�|dvr|j��}|j�|�|dkrZ|j�|j|jf�t|jt|j��|_g|_d|_|dkr�|�	|j�}|j
�|�g|_d|_d|_dS)N)rWZtd�trFrKrk)rUrDrRr�r�rVrrSr�generate_tablerQrT)r`rXZstripped_contentrKrrr�
handle_endtagfs 

�zTableHandler.handle_endtagcCs|j|7_dSr))rU)r`�datarrr�handle_dataxszTableHandler.handle_datacCs�tfi|j��}|jD]z}t|d�|jkr\|jt|d�}td|�D]}|d�d�qH|ddkr�|�|d�|d|_q|�	|d�q|S)zE
        Generates from a list of rows a PrettyTable object.
        rrr5T)
rrar�rrSr�r��make_fields_uniquerBrw)r`r�rKr}Zappendsr�rrrr\{s
zTableHandler.generate_tablecCsPtdt|��D]<}t|dt|��D]$}||||kr$||d7<q$qdS)zB
        iterates over the row and make each field unique
        rr�'N)r�r)r`rr��jrrrr`�szTableHandler.make_fields_uniqueN)	r0r1r2rcrZr]r_r\r`rrrrrPTsrPcKstfi|��}|�|�|jS)z�
    Generates a list of PrettyTables from a string of HTML code. Each <table> in
    the HTML becomes one PrettyTable object.
    )rPZfeedrQ)�	html_codera�parserrrr�	from_html�s
recKs8t|fi|��}zWnty.td��Yn0|dS)zf
    Generates a PrettyTables from a string of HTML code which contains only a
    single <table>
    zDMore than one <table> in provided HTML code!  Use from_html instead.r)rer�ry)rcrarQrrr�
from_html_one�srfcCs�tgd��}d|_d|_d|jd<d|_d|jd<|�gd	��|�gd
��|�gd��|�gd��|�gd
��|�gd��|�gd��t|�dS)N)�	City name�Area�
PopulationzAnnual RainfallriTZ04drhz6.1frjrg)ZAdelaideiis�gĂ@)ZBrisbaneii:Xg������@)ZDarwin�piD�g�����ʚ@)ZHobartiMi�"g\�@)ZSydneyi
i�*Bg33333��@)Z	Melbourneii�:g333337�@)ZPerthi
iQ�g33333+�@)rr&r'r-r.rmrw�printr*rrr�main�s

rl�__main__)N)2�__version__r�rEr��re�sysr�	itertoolsr:�version_infor3rgrhrf�mapr?r�Ziterzip�chrr;Zhtml.parserr�imapZizipZunichrZhtmlrZcgirMrOr�r�r�r�r�r��compilerAr�objectrr=rrLrOrPrerfrlr0rrrr�<module> sj
E!
	B



© 2025 Cubjrnet7