• File: prettytable.cpython-37.pyc
  • Full Path: /home3/farmfre2/public_html/ALFA_DATA/alfasymlink/root/opt/alt/python37/lib/python3.7/site-packages/__pycache__/prettytable.cpython-37.pyc
  • Date Modified: 06/27/2022 10:01 PM
  • File size: 43.89 KB
  • MIME-type: text/x-bytecode.python
  • Charset: 8 bit
B

F`Q@s`dZddlZddlZddlZddlZddlZddlZddlZddlZej	ddkZ
e
rxeZeZ
eZeZeZddlmZnejZejZeZddlmZe
rej	ddkrddlmZnddlmZdZdZdZdZdZ d	Z!d
Z"dZ#e$dZ%d
dZ&Gddde'Z(ddZ)ddZ*d"ddZ+ddZ,GdddeZ-ddZ.ddZ/dd Z0e1d!kr\e0dS)#z0.7.2N)
HTMLParser)escape
z\[[0-9;]*mcCs,|d}t|}tdd|D}||fS)N
cSsg|]}t|qS)_str_block_width).0linerr</opt/alt/python37/lib/python3.7/site-packages/prettytable.py
<listcomp>Osz_get_size.<locals>.<listcomp>)splitlenmax)textlinesZheightwidthrrr	_get_sizeLs
rc@sBeZdZdddZddZddZdd	Zd
dZer@dd
Z	ndd
Z	ddZ
ddZddZddZ
ddZddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1d2Zd3d4ZeeeZd5d6Zd7d8Z eee Z!d9d:Z"d;d<Z#ee"e#Z$d=d>Z%d?d@Z&ee%e&Z'dAdBZ(dCdDZ)ee(e)Z*dEdFZ+dGdHZ,ee+e,Z-dIdJZ.dKdLZ/ee.e/Z0dMdNZ1dOdPZ2ee1e2Z3dQdRZ4dSdTZ5ee4e5Z6dUdVZ7dWdXZ8ee7e8Z9dYdZZ:d[d\Z;ee:e;Z<d]d^Z=d_d`Z>ee=e>Z?dadbZ@dcddZAee@eAZBdedfZCdgdhZDeeCeDZEdidjZFdkdlZGeeFeGZHdmdnZIdodpZJeeIeJZKdqdrZLdsdtZMeeLeMZNdudvZOdwdxZPeeOePZQdydzZRd{d|ZSeeReSZTd}d~ZUddZVeeUeVZWddZXddZYeeXeYZZddZ[ddZ\ee[e\Z]ddZ^ddZ_ee^e_Z`ddZaddZbeeaebZcddZdddZeeedeeZfddZgddZheegehZiddZjddZkddZlddZmddZnddZoddZpddZqdddZrddZsddZtddZuddZvddZwddZxddZyddZzddZ{ddZ|dd„Z}ddĄZ~ddƄZddȄZddʄZdd̄ZdS)PrettyTableNcKsZ|dd|_g|_i|_i|_i|_g|_|r8||_ng|_d	|_
|j
d	|j
d	x0|j
D]&}||kr||||qpd||<qpW|dpd|_
|d	pd|_|d
pd|_|ddkr|d|_nd
|_|dpd|_|ddkr
|d|_nd
|_|dpt|_|dp,t|_|dp<d|_|ddkrZ|d|_nd|_|dppdd|_|dpi|_|dpi|_|dpd|_|dpd|_|dpd|_|dp|d|_ |d p|d!|_!|d"p|d#|_"|d$dkr |d$|_#nd
|_#|d%p2d|_$|d&pBd|_%|d'pRi|_&dS)(aReturn 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 orderencodingzUTF-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_emptyNstartrendfieldsheader)TFTheader_styleborderhrulesvrulessortbyreversesortFsort_keycSs|S)Nr)xrrr<lambda>z&PrettyTable.__init__.<locals>.<lambda>
int_formatfloat_format
padding_widthrleft_padding_widthright_padding_width
vertical_char|horizontal_char-
junction_char+print_emptyformatxhtml
attributes)'getr_field_names_align_valign
_max_width_rowsfield_names_widthsr_optionsextend_validate_option_start_end_fields_header
_header_style_borderFRAME_hrulesALL_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)selfr>kwargsoptionrrr__init__Ts^
zPrettyTable.__init__cCs.t|tst|}t|ts*t||jd}|S)Nstrict)
isinstance
basestringstrunicoder)r\valuerrrrUs


zPrettyTable._unicodecCs|t|}|dkr ||dS|dkr4|d|S|drt|drh|dd||dddS|ddd||ddSn|dd||ddSdS)Nl rrr)r
)r\rralignZexcessrrr_justifys "zPrettyTable._justifycCsP|dkrt|jS|dkrD|jr*t|jS|jr>t|jdSdSnt|dS)NrowcountZcolcountr)rr=r9AttributeError)r\namerrr__getattr__s

zPrettyTable.__getattr__cCst}|j|_x(|jD]}t|d|t|d|qWt|dt|dt|trtxJ|j|D]}||q`Wn,t|t	r||j|nt
dt||S)N_r:z0Index %s is invalid, must be an integer or slice)rr>r@setattrgetattrraslicer=add_rowint	Exceptionrc)r\indexnewattrrowrrr__getitem__s

zPrettyTable.__getitem__cCs|S)N)__unicode__)r\rrr__str__szPrettyTable.__str__cCs||jS)N)r{encoder)r\rrrr|scCs|S)N)
get_string)r\rrrr{szPrettyTable.__unicode__cCs2|dkr||n|dkr.|||n|dkrD|||n|dkrZ|||n|dkrp|||n|dkr|||n|dkr|||n|dkr|||n||d	kr||nh|d
kr|	||nR|dkr|
||n<|dkr
|||n$|d
kr"|||nt
d|dS)Nr>)rr	max_widthr+r,r-r5r#r%r!r"r)rr r$r6r4rr)r*)r.r0r2r7zUnrecognised 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_attributesru)r\r^valrrrrBs6

zPrettyTable._validate_optionc	Cs|jrPyt|t|jkstWn.tk
rNtdt|t|jfYnX|jryt|t|jdksrtWn2tk
rtdt|t|jdfYnXyt|tt|kstWntk
rtdYnXdS)NzJField name list has incorrect number of values, (actual) %d!=%d (expected)rzField names must be unique!)r9rAssertionErrorrur=set)r\rrrrrs $z!PrettyTable._validate_field_namescCs2y|dkstWntk
r,tdYnXdS)N)captitleupperlowerNz;Invalid header style, use cap, title, upper, lower or None!)rru)r\rrrrr0sz"PrettyTable._validate_header_stylecCs6y|dkstWn tk
r0td|YnXdS)N)rfcrhz'Alignment %s is invalid, use l, c or r!)rru)r\rrrr_validate_align6szPrettyTable._validate_aligncCs6y|dkstWn tk
r0td|YnXdS)N)tmbNz-Alignment %s is invalid, use t, m, b or None!)rru)r\rrrr_validate_valign<szPrettyTable._validate_valignc	CsDyt|dkstWn*tk
r>td|||fYnXdS)NrzInvalid value for %s: %s!)rtrrurU)r\rmrrrrrBsz%PrettyTable._validate_nonnegative_intcCs6y|dkstWn tk
r0td|YnXdS)N)TFz-Invalid value for %s!  Must be True or False.)rru)r\rmrrrrrHsz#PrettyTable._validate_true_or_falsecCsV|dkrdSy$t|ttfks"t|s.tWn tk
rPtd|YnXdS)Nz8Invalid value for %s!  Must be an integer format string.)typercrdrisdigitru)r\rmrrrrrNsz PrettyTable._validate_int_formatcCs|dkrdSyvt|ttfks"td|ks.t|d}t|dksHt|ddksd|dsdt|ddks|dstWn tk
rtd|YnXdS)Nr.rrrz5Invalid value for %s!  Must be a float format string.)rrcrdrrrrru)r\rmrbitsrrrrWs
 z"PrettyTable._validate_float_formatcCs8yt|dstWn tk
r2td|YnXdS)N__call__z*Invalid value for %s!  Must be a function.)hasattrrru)r\rmrrrrrdszPrettyTable._validate_functioncCs>y|ttttfkstWn tk
r8td|YnXdS)Nz:Invalid value for %s!  Must be ALL, FRAME, HEADER or NONE.)rKrIHEADERNONErru)r\rmrrrrrjszPrettyTable._validate_hrulescCs<y|tttfkstWn tk
r6td|YnXdS)Nz3Invalid value for %s!  Must be ALL, FRAME, or NONE.)rKrIrrru)r\rmrrrrrpszPrettyTable._validate_vrulescCs@y||jks|dkstWn tk
r:td|YnXdS)NzInvalid field name: %s!)r9rru)r\rmrrrrrvsz PrettyTable._validate_field_namecCs@yx|D]}|||qWWntk
r:tdYnXdS)Nz)fields must be a sequence of field names!)rrru)r\rmrr&rrrr|s

z%PrettyTable._validate_all_field_namescCs:yt|dkstWn tk
r4td|YnXdS)Nrz4Invalid value for %s!  Must be a string of length 1.)r
rru)r\rmrrrrrsz!PrettyTable._validate_single_charcCs4yt|tstWntk
r.tdYnXdS)Nz4attributes must be a dictionary of name/value pairs!)radictrru)r\rmrrrrrsz PrettyTable._validate_attributescCs|jS)N)r9)r\rrr_get_field_namesszPrettyTable._get_field_namescs&fdd|D}d|jr2jdd}|_jr|rx&t||D]\}}j|j|<qNWx>|D]}|jkrpj|qpWnxjD]}dj|<qWjr|rx&t||D]\}}j|j|<qWx@|D]}|jkrj|qWnxjD]}dj|<qWdS)Ncsg|]}|qSr)rU)rr&)r\rrrsz0PrettyTable._set_field_names.<locals>.<listcomp>r>rr)rBr9r:zippopr;)r\rZ	old_namesZold_namenew_namefieldr)r\r_set_field_namess*




zPrettyTable._set_field_namescCs|jS)N)r:)r\rrr
_get_alignszPrettyTable._get_aligncCs(||x|jD]}||j|<qWdS)N)rr9r:)r\rrrrr
_set_aligns
zPrettyTable._set_aligncCs|jS)N)r;)r\rrr_get_valignszPrettyTable._get_valigncCs(||x|jD]}||j|<qWdS)N)rr9r;)r\rrrrr_set_valigns
zPrettyTable._set_valigncCs|jS)N)r<)r\rrr_get_max_widthszPrettyTable._get_max_widthcCs*|d|x|jD]}||j|<qWdS)Nr)rBr9r<)r\rrrrr_set_max_widthszPrettyTable._set_max_widthcCs|jS)zList or tuple of field names to include in displays

        Arguments:

        fields - list or tuple of field names to include in displays)rE)r\rrr_get_fieldsszPrettyTable._get_fieldscCs|d|||_dS)Nr)rBrE)r\rrrr_set_fieldss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)rC)r\rrr
_get_startszPrettyTable._get_startcCs|d|||_dS)Nr)rBrC)r\rrrr
_set_startszPrettyTable._set_startcCs|jS)zEnd index of the range of rows to print

        Arguments:

        end - index of last data row to include in output PLUS ONE (list slice style))rD)r\rrr_get_endszPrettyTable._get_endcCs|d|||_dS)Nr)rBrD)r\rrrr_set_endszPrettyTable._set_endcCs|jS)z_Name of field by which to sort rows

        Arguments:

        sortby - field name to sort by)rM)r\rrr_get_sortbyszPrettyTable._get_sortbycCs|d|||_dS)Nr#)rBrM)r\rrrr_set_sortbyszPrettyTable._set_sortbycCs|jS)zControls direction of sorting (ascending vs descending)

        Arguments:

        reveresort - set to True to sort by descending order, or False to sort by ascending order)rN)r\rrr_get_reversesortszPrettyTable._get_reversesortcCs|d|||_dS)Nr$)rBrN)r\rrrr_set_reversesortszPrettyTable._set_reversesortcCs|jS)zSorting key function, applied to data points before sorting

        Arguments:

        sort_key - a function which takes one argument and returns something to be sorted)rO)r\rrr
_get_sort_key	szPrettyTable._get_sort_keycCs|d|||_dS)Nr%)rBrO)r\rrrr
_set_sort_keyszPrettyTable._set_sort_keycCs|jS)zControls printing of table header with field names

        Arguments:

        header - print a header showing field names (True or False))rF)r\rrr_get_headerszPrettyTable._get_headercCs|d|||_dS)Nr)rBrF)r\rrrr_set_headerszPrettyTable._set_headercCs|jS)zControls stylisation applied to field names in header

        Arguments:

        header_style - stylisation to apply to field names in header ("cap", "title", "upper", "lower" or None))rG)r\rrr_get_header_style!szPrettyTable._get_header_stylecCs||||_dS)N)rrG)r\rr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))rH)r\rrr_get_border-szPrettyTable._get_bordercCs|d|||_dS)Nr )rBrH)r\rrrr_set_border4szPrettyTable._set_bordercCs|jS)zControls printing of horizontal rules after rows

        Arguments:

        hrules - horizontal rules style.  Allowed values: FRAME, ALL, HEADER, NONE)rJ)r\rrr_get_hrules9szPrettyTable._get_hrulescCs|d|||_dS)Nr!)rBrJ)r\rrrr_set_hrules@szPrettyTable._set_hrulescCs|jS)zControls printing of vertical rules between columns

        Arguments:

        vrules - vertical rules style.  Allowed values: FRAME, ALL, NONE)rL)r\rrr_get_vrulesEszPrettyTable._get_vrulescCs|d|||_dS)Nr")rBrL)r\rrrr_set_vrulesLszPrettyTable._set_vrulescCs|jS)zbControls formatting of integer data
        Arguments:

        int_format - integer format string)rP)r\rrr_get_int_formatQszPrettyTable._get_int_formatcCsx|jD]}||j|<qWdS)N)r9rP)r\rrrrr_set_int_formatWszPrettyTable._set_int_formatcCs|jS)zrControls formatting of floating point data
        Arguments:

        float_format - floating point format string)rQ)r\rrr_get_float_format]szPrettyTable._get_float_formatcCsx|jD]}||j|<qWdS)N)r9rQ)r\rrrrr_set_float_formatcszPrettyTable._set_float_formatcCs|jS)zThe number of empty spaces between a column's edge and its content

        Arguments:

        padding_width - number of spaces, must be a positive integer)rR)r\rrr_get_padding_widthiszPrettyTable._get_padding_widthcCs|d|||_dS)Nr+)rBrR)r\rrrr_set_padding_widthpszPrettyTable._set_padding_widthcCs|jS)zThe number of empty spaces between a column's left edge and its content

        Arguments:

        left_padding - number of spaces, must be a positive integer)rS)r\rrr_get_left_padding_widthusz#PrettyTable._get_left_padding_widthcCs|d|||_dS)Nr,)rBrS)r\rrrr_set_left_padding_width|sz#PrettyTable._set_left_padding_widthcCs|jS)zThe number of empty spaces between a column's right edge and its content

        Arguments:

        right_padding - number of spaces, must be a positive integer)rT)r\rrr_get_right_padding_widthsz$PrettyTable._get_right_padding_widthcCs|d|||_dS)Nr-)rBrT)r\rrrr_set_right_padding_widthsz$PrettyTable._set_right_padding_widthcCs|jS)zThe charcter used when printing table borders to draw vertical lines

        Arguments:

        vertical_char - single character string used to draw vertical lines)rV)r\rrr_get_vertical_charszPrettyTable._get_vertical_charcCs ||}|d|||_dS)Nr.)rUrBrV)r\rrrr_set_vertical_chars
zPrettyTable._set_vertical_charcCs|jS)zThe charcter used when printing table borders to draw horizontal lines

        Arguments:

        horizontal_char - single character string used to draw horizontal lines)rW)r\rrr_get_horizontal_charsz PrettyTable._get_horizontal_charcCs ||}|d|||_dS)Nr0)rUrBrW)r\rrrr_set_horizontal_chars
z PrettyTable._set_horizontal_charcCs|jS)zThe charcter used when printing table borders to draw line junctions

        Arguments:

        junction_char - single character string used to draw line junctions)rX)r\rrr_get_junction_charszPrettyTable._get_junction_charcCs ||}|d|||_dS)Nr.)rUrBrX)r\rrrr_set_junction_chars
zPrettyTable._set_junction_charcCs|jS)z~Controls whether or not HTML tables are formatted to match styling options

        Arguments:

        format - True or False)rZ)r\rrr_get_formatszPrettyTable._get_formatcCs|d|||_dS)Nr5)rBrZ)r\rrrr_set_formatszPrettyTable._set_formatcCs|jS)zControls whether or not empty tables produce a header and frame or just an empty string

        Arguments:

        print_empty - True or False)rY)r\rrr_get_print_emptyszPrettyTable._get_print_emptycCs|d|||_dS)Nr4)rBrY)r\rrrr_set_print_emptyszPrettyTable._set_print_emptycCs|jS)zA 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_attributesszPrettyTable._get_attributescCs|d|||_dS)Nr7)rBr[)r\rrrr_set_attributesszPrettyTable._set_attributescCsPi}xF|jD]<}||kr6||||||||<qt|d|||<qW|S)Nro)r@rBrq)r\r]optionsr^rrr_get_optionsszPrettyTable._get_optionscCsT|tkr|n>|tkr$|n,|tkr6|n|tkrH|ntddS)NzInvalid pre-set style!)	DEFAULT_set_default_styleMSWORD_FRIENDLY_set_msword_style
PLAIN_COLUMNS_set_columns_styleRANDOM_set_random_styleru)r\Zstylerrr	set_styles



zPrettyTable.set_stylecCs@d|_d|_t|_t|_d|_d|_d|_d|_	d|_
d|_dS)NTrr/r1r3)rr rIrJrKrLr+r,r-r.r0r2)r\rrrrszPrettyTable._set_default_stylecCs.d|_d|_t|_d|_d|_d|_d|_dS)NTrr/)rr rrJr+r,r-r.)r\rrrrszPrettyTable._set_msword_stylecCs"d|_d|_d|_d|_d|_dS)NTFrr)rr r+r,r-)r\rrrrs
zPrettyTable._set_columns_stylecCstd|_td|_tttttf|_ttttf|_	t
dd|_t
dd|_td|_
td|_td|_dS)N)TFrz ~!@#$%^&*()_+|-=\{}[];':",./;<>?)randomZchoicerr rKrIrrrJrLZrandintr,r-r.r0r2)r\rrrrszPrettyTable._set_random_stylecCsf|jr2t|t|jkr2tdt|t|jf|jsRddtdt|D|_|jt|dS)zAdd 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|dqS)zField %drr)rnrrrr4sz'PrettyTable.add_row.<locals>.<listcomp>rN)r9rruranger>r=appendlist)r\ryrrrrs(s
	zPrettyTable.add_rowcCs4|t|jdkr(td|t|jf|j|=dS)zDelete 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)rr=ru)r\Z	row_indexrrrdel_row7szPrettyTable.del_rowrrcCst|jdt|fkr|||||j|||j|<||j|<xdtdt|D]6}t|j|dkr||jg|j|||qZWnt	dt|t|jfdS)aAdd 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)
rr=rrr9rr:r;rru)r\	fieldnamecolumnrivalignirrr
add_columnCs



zPrettyTable.add_columncCs
g|_dS)z?Delete all rows from the table but keep the current field namesN)r=)r\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)r=r9r?)r\rrrclearbszPrettyTable.clearcCs
t|S)N)copydeepcopy)r\rrrrnszPrettyTable.copycCsdt|tr.||jkr.|d|j||}n,t|trZ||jkrZ|d|j||}||S)Nz%%%sdz%%%sf)rartrPrUfloatrQ)r\rrerrr
_format_valueus
zPrettyTable._format_valuecCs|drdd|jD}nt|jdg}xx|D]p}xjt|D]^\}}|j|}||jkrt||tt|d|j|||<q>t||t|d||<q>Wq0W||_dS)NrcSsg|]}t|dqS)r)r)rrrrrr~sz/PrettyTable._compute_widths.<locals>.<listcomp>r)	r9rr>	enumeraterrminrr?)r\rowsrZwidthsryrvrerrrr_compute_widths|s


("zPrettyTable._compute_widthscCsD|ddk	r|d}n|d}|ddk	r4|d}n|d}||fS)Nr,r+r-r)r\rlpadrpadrrr_get_padding_widthss

zPrettyTable._get_padding_widthscsnt|j|d|d}|drj|j|dfdd|D}|j|d|ddd	d|D}|S)
zReturn only those data rows that should be printed, based on slicing and sorting.

        Arguments:

        options - dictionary of option settings.rrr#csg|]}|g|qSrr)rry)	sortindexrrrsz)PrettyTable._get_rows.<locals>.<listcomp>r$r%)reversekeycSsg|]}|ddqS)rNr)rryrrrrs)rrr=r9rvsort)r\rrr)rr	_get_rowsszPrettyTable._get_rowscsfddtj|DS)Ncsg|]\}}||qSr)r)rrre)r\rrrsz+PrettyTable._format_row.<locals>.<listcomp>)rr9)r\ryrr)r\r_format_rowszPrettyTable._format_rowcsfdd|DS)Ncsg|]}|qSr)r)rry)rr\rrrsz,PrettyTable._format_rows.<locals>.<listcomp>r)r\rrr)rr\r_format_rowsszPrettyTable._format_rowscKs||}g}|jdkr,|dr(|ds,dS||}|||}||||||_|drt|||n$|dr|dt	t
fkr||jx|D]}||||qW|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 rr4r rrr!r)rrkrrr_stringify_hrule_hruler_stringify_headerrKrI_stringify_rowrUjoin)r\r]rrrformatted_rowsryrrrr~s"


zPrettyTable.get_stringcCs|dsdS||\}}|dttfkr6|dg}n
|dg}|js^||dd|Sxtt|j|jD]b\}}|dr||dkrqn|||||d|dtkr||dqn||dqnW|dtkr|||dd|S)Nr rr"r2r0r)	rrKrIr9rrrr?r)r\rrrrrrrrrrs(

zPrettyTable._stringify_hrulec
Csg}||\}}|drj|dttfkr@||j|d|dttfkr`||dn
|d|js|dttfkr||dn
|dxt|j|jD]\}}|dr||dkrq|jdkr|	}nD|jd	kr|
}n0|jd
kr|}n|jdkr|}n|}|d||
|||j|d||dr|dtkrp||dq|dqW|dr|dtkr|||d|dr|dtkr|d||jd|S)
Nr r!rr"r.rgrrrrrr)rrKrIrr	r9rr?rG
capitalizerrrrjr:rrr)r\rrrrrrrrrrr
sJ








*
zPrettyTable._stringify_headercCsxttdt||j||jD]`\}}}}|d}g}x.|D]&}	t|	|krZt|	|}	|	|	q>W|}d
|}|||<qWd}
x$|D]}t|d}||
kr|}
qWg}
||\}}xVtd|
D]H}|
	g|dr|dt
tfkr|
|	|jq|
|	dqWxFt|j||jD]0\}}}|j|}|d}|
t|}|r|dkrdgt|d	|dg|t|d	}n(|d
krdg||}n|dg|}d}x|D]}|dr||dkrq|
|	d|||||j|d||drL|dt
kr>|
|	|jn|
|	d|d7}qWq*WxJtd|
D]<}|drl|dtkrl|
||
|	|dqlW|dr|d
t
kr|
|
d	d|
|
d	|jx&td|
D]}d
|
||
|<qWd
|
S)Nrrrr r"rgrrrrrr.r!)rrrr9r?rr
textwrapZfillrrrrrKrIr.r;rtrjr:rr	)r\ryrrvrrerrZ	new_linesrZ
row_heightrhrrryrZdHeightrfr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 falser5)r_get_formatted_html_string_get_simple_html_string)r\r]rstringrrrget_html_strings


zPrettyTable.get_html_stringc	Csrg}|drd}nd}g}|d|drXx*|dD]}|d||d|fq6W|d|d||d	r|d
x>|jD]4}|dr||dkrq|dt|d
|qW|d||}|||}xr|D]j}	|d
xPt|j|	D]@\}}
|dr*||dkr*q|dt|
d
|qW|dqW|d|d
|S)Nr6z<br/>z<br>z<tabler7z %s="%s">rrz    <tr>rz        <th>%s</th>rz	    </tr>z        <td>%s</td>z</table>)	rrr9rreplacerrrrU)r\rr	linebreakopen_tag	attr_namerrr
rydatumrrrrs:






 
z#PrettyTable._get_simple_html_stringc
Csg}||\}}|dr d}nd}g}|d|dr|dtkr`|dtkr`|dn|dtkr|dtkr|d	n|dtkr|dtkr|d
n`|dtkr|dnH|dtkr|dn0|dtkr|d
n|dtkr|d|dr@x,|dD] }|d||d|fqW|d|d||dr|dxL|jD]B}|dr||dkrqv|d||t|d|fqvW|d||}	|	|	|}
g}g}xH|jD]>}|dddd|j
||dddd |j|qWx|
D]~}
|dxbt|j|
||D]N\}}}}|dr|||dkr|qT|d!||||t|d|fqTW|dq4W|d"|
d|S)#Nr6z<br/>z<br>z<tabler 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"r7z %s="%s"rrrz    <tr>rzW        <th style="padding-left: %dem; padding-right: %dem; text-align: center">%s</th>rz	    </tr>leftrightcenter)rfrhrtopZmiddleZbottom)rrrzg        <td style="padding-left: %dem; padding-right: %dem; text-align: %s; vertical-align: %s">%s</td>z</table>)rrrKrIrr9rrrrr:r;rrU)r\rrrrrrrrrr
ZalignsZvalignsryrrirrrrrsd



 


&

"

*
z&PrettyTable._get_formatted_html_string)N)rr)__name__
__module____qualname__r_rUrjrnrzpy3kr|r{rBrrrrrrrrrrrrrrrrrpropertyr>rrrirrrrrrrrrrrrrrrrrr#rrr$rrr%rrrrrrrrr rrr!rrr"rrr)rrr*rrr+rrr,rrr-rrr.rrr0rrr2rrr5rrr4rrr7rrrrrrrsrrrrrrrrrrrr~rr
rrrrrrrrrRs
]
	































=/L (rcCsd|krdkrnndSd|kr0dkr8nndSd|krLdkrTnndStt|rfd	Sd
|krzdksnd|krd
krnndSd|krdkrnndSd|krdkrnndS|dkrdS|dkrd	SdS)N!~riNiriiri@0i0i0i0ii`i0i>0)r)r)unicodedataZ	combininguni_chr)charrrr_char_block_widths&.r-c	Csttttttd|S)Nr)sumitermapr-ord_resub)rrrrr
/sr
cKst|d}|dt||}tf|}|r@||_n.trZddt	|D|_ndd|	D|_x |D]}|
dd|DqtW|S)NircSsg|]}|qSr)strip)rr&rrrrBszfrom_csv.<locals>.<listcomp>cSsg|]}|qSr)r3)rr&rrrrDscSsg|]}|qSr)r3)rr&rrrrGs)csvZSnifferZsniffreadseekreaderrr>r#nextrs)fpr>r]Zdialectr7tableryrrrfrom_csv7s


r;cKsF|jrBtf|}dd|jD|_x|D]}||q,W|SdS)NcSsg|]}|dqS)rr)rcolrrrrOsz"from_db_cursor.<locals>.<listcomp>)descriptionrr>Zfetchallrs)Zcursorr]r:ryrrrfrom_db_cursorKs
r>c@s<eZdZddZddZddZddZd	d
ZddZd
S)TableHandlercKs>t|||_g|_g|_g|_d|_d|_d|_d|_	dS)NrrF)
rr_r]tableslast_rowr
max_row_widthactivelast_contentis_last_row_header)r\r]rrrr_Vs
zTableHandler.__init__cCs||_|dkrd|_dS)NthT)rCrE)r\tagZattrsrrrhandle_starttagaszTableHandler.handle_starttagcCs|dkr|j}|j||dkrZ|j|j|jft|jt|j|_g|_d|_|dkr|	|j}|j
|g|_d|_d|_dS)N)rFZtdZtrFr:rg)rDr3rArrrErrBrgenerate_tabler@rC)r\rGZstripped_contentr:rrr
handle_endtagfs
zTableHandler.handle_endtagcCs|j|7_dS)N)rD)r\datarrrhandle_dataxszTableHandler.handle_datacCstf|j}x|jD]~}t|d|jkr^|jt|d}x td|D]}|ddqHW|ddkr||d|d|_q|	|dqW|S)zE
        Generates from a list of rows a PrettyTable object.
        rrr1T)
rr]rrrBrrmake_fields_uniquer>rs)r\rr:ryZappendsrrrrrI{szTableHandler.generate_tablecCsXxRtdt|D]@}x:t|dt|D]$}||||kr(||d7<q(WqWdS)zB
        iterates over the row and make each field unique
        rr'N)rr)r\rrjrrrrMszTableHandler.make_fields_uniqueN)	r r!r"r_rHrJrLrIrMrrrrr?Tsr?cKstf|}|||jS)z
    Generates a list of PrettyTables from a string of HTML code. Each <table> in
    the HTML becomes one PrettyTable object.
    )r?Zfeedr@)	html_coder]parserrrr	from_htmls

rRcKsFt|f|}yt|dkstWntk
r<tdYnX|dS)zf
    Generates a PrettyTables from a string of HTML code which contains only a
    single <table>
    rzDMore than one <table> in provided HTML code!  Use from_html instead.r)rRrrru)rPr]r@rrr
from_html_onesrScCstddddg}d|_d|_d|jd<d|_d|jd<|d	d
ddg|d
dddg|ddddg|ddddg|ddddg|dddd g|d!d"d#d$gt|dS)%Nz	City nameZAreaZ
PopulationzAnnual RainfallTZ04dz6.1frfZAdelaideiisgĂ@ZBrisbaneii:Xg@ZDarwinpiDgʚ@ZHobartiMi"g\@ZSydneyi
i*Bg33333@Z	Melbourneii:g333337@ZPerthi
iQg33333+@)rr#r$r)r*rirsprint)r&rrrmains

rV__main__)N)2__version__rr4rresysr	itertoolsr*version_infor#rcrdrbmapr/rZiterzipchrr+Zhtml.parserrZimapZizipZunichrZhtmlrZcgirIrKrrrrrrcompiler1robjectrr-r
r;r>r?rRrSrVr rrrr<module> sj
E!
	B