U §?’gÜqã@sÔddlmZddlZddlZddlmZddlmZdZdZ dZ dZ dZ d Z d Zd Zd Zd ZdZdZdZe d¡Zdd„ZGdd„dƒZdd„Zd&ddœdd„Zdd„Zdd„ZGd d!„d!eƒZd"d#„Zd$d%„ZdS)'é)Ú annotationsN)Ú HTMLParser)ÚAnyéééé é é é ééééZbase_align_valuez\033\[[0-9;]*m|\033\(BcCs,| d¡}t|ƒ}tdd„|Dƒƒ}||fS)NÚ css|]}t|ƒVqdS©N©Ú_str_block_width)Ú.0Úline©rúH/opt/alt/python38/lib/python3.8/site-packages/prettytable/prettytable.pyÚ @sz_get_size..)ÚsplitÚlenÚmax)ÚtextÚlinesÚheightÚwidthrrrÚ _get_size=s r c@s eZdZd*ddœdd„Zdd„Zdd „Zd d „Zd dœd d„Zd dœdd„Zdd„Z ddœdd„Z dd„Z dd„Z dd„Z dd„Zdd„Zdd „Zd!d"„Zd#d$„Zd%d&„Zd'd(„Zd)d*„Zd+d,„Zd-d.„Zd/d0„Zd1d2„Zd3d4„Zed5dœd6d7„ƒZed8dœd9d:„ƒZed;dœdd=„ƒZed?d@„ƒZ e jdAd@„ƒZ edBdC„ƒZ!e!jddœdDdC„ƒZ!edEdF„ƒZ"e"jddœdGdF„ƒZ"edHdI„ƒZ#e#jddœdJdI„ƒZ#edKdL„ƒZ$e$jddœdMdL„ƒZ$edNdO„ƒZ%e%jddœdPdO„ƒZ%edQdR„ƒZ&e&jddœdSdR„ƒZ&edTdU„ƒZ'e'jddœdVdU„ƒZ'edWdX„ƒZ(e(jddœdYdX„ƒZ(edZd[„ƒZ)e)jddœd\d[„ƒZ)ed]d^„ƒZ*e*jddœd_d^„ƒZ*ed`da„ƒZ+e+jddœdbda„ƒZ+edcdd„ƒZ,e,jddœdedd„ƒZ,edfdg„ƒZ-e-jddœdhdg„ƒZ-edidj„ƒZ.e.jddœdkdj„ƒZ.edldm„ƒZ/e/jddœdndm„ƒZ/edodp„ƒZ0e0jddœdqdp„ƒZ0edrds„ƒZ1e1jddœdtds„ƒZ1edudv„ƒZ2e2jddœdwdv„ƒZ2edxdy„ƒZ3e3jddœdzdy„ƒZ3ed{d|„ƒZ4e4jddœd}d|„ƒZ4ed~d„ƒZ5e5jddœd€d„ƒZ5edd‚„ƒZ6e6jddœdƒd‚„ƒZ6ed„d…„ƒZ7e7jd†d…„ƒZ7ed‡dˆ„ƒZ8e8jddœd‰dˆ„ƒZ8edŠd‹„ƒZ9e9jddœdŒd‹„ƒZ9eddŽ„ƒZ:e:jddœddŽ„ƒZ:edd‘„ƒZ;e;jddœd’d‘„ƒZ;ed“d”„ƒZe>jddœd›dš„ƒZ>edœd„ƒZ?e?jddœdžd„ƒZ?edŸd „ƒZ@e@jddœd¡d „ƒZ@ed¢d£„ƒZAeAjddœd¤d£„ƒZAed¥d¦„ƒZBeBjddœd§d¦„ƒZBed¨d©„ƒZCeCjddœdªd©„ƒZCed«d¬„ƒZDeDjddœd­d¬„ƒZDed®d¯„ƒZEeEjddœd°d¯„ƒZEed±d²„ƒZFeFjddœd³d²„ƒZFed´dµ„ƒZGeGjddœd¶dµ„ƒZGed·d¸„ƒZHeHjddœd¹d¸„ƒZHedºd»„ƒZIeIjddœd¼d»„ƒZIed½d¾„ƒZJeJjddœd¿d¾„ƒZJedÀdÁ„ƒZKeKjdÂdÁ„ƒZKedÃdÄ„ƒZLeLjdÅdÄ„ƒZLdÆdÇ„ZMddœdÈdÉ„ZNddœdÊdË„ZOddœdÌdÍ„ZPddœdÎdÏ„ZQddœdÐdÑ„ZRddœdÒdÓ„ZSddœdÔdÕ„ZTddœdÖdׄZUddœdØdÙ„ZVddœdÚdÛ„ZWdÜdÝœd;ddÞœdßdà„ZXddœdádâ„ZYd+d d ddåœdædç„ZZd,d ddéœdêdë„Z[ddœdìdí„Z\ddœdîdï„Z]ddœdðdñ„Z^dòdó„Z_d-d d dõœdöd÷„Z`dødù„Zadúdû„Zbddœdüdý„Zcdþdÿ„Zddd„Zedd„Zfdd„Zgdd„Zhd dœdd „Zid.d d œd d „Zjdd„Zkdd„Zldd„Zmd/dd dœdd„Znd dœdd„Zod dœdd„Zpd dœdd„Zqd d!„Zrd"d#„Zsd dœd$d%„Ztd&d'„Zud(d)„ZvdS(0Ú PrettyTableNÚNone©Úreturnc.Ks(| dd¡|_g|_g|_g|_i|_i|_i|_i|_i|_ i|_ i|_ d|_ |r\||_ ng|_dddddd d d d d ddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+dd,d-d.d/d0g.|_|jD]&}||krè| |||¡qÊd||<qÊ|dpüd|_|dp d1|_|dpd|_|dp,d|_i|_|dd2krP|d|_nd3|_|dpbd|_|d d2kr€|d |_nd3|_|d d2kr |d |_nd4|_|dp²t|_|dpÂt|_|d pÒd|_|d d2krð|d |_nd4|_|d pd5d6„|_ |d0d2kr$|d0|_!nd3|_!|d/d2krD|d/|_"nd3|_"|d+pVi|_|dpfi|_|d,pvi|_|d-p†i|_|dp–i|_ |dp¦i|_ |dp¶i|_ |d.pÆi|_#|dpÖd|_$|dpæd|_%|ddkrd7|_&n |d|_&|dpd|_'|dp&d|_(|dp6d8|_)|dpFd9|_*|d|_+|dp`d:|_,|d#|_-|d$|_.|d%|_/|d&|_0|d'|_1|d(|_2|d)|_3|d*|_4|d!d2krÎ|d!|_5nd3|_5|d"d2krî|d"|_6nd4|_6|dpd4|_7|d pd4|_8|dp i|_9dS);aý 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-8NÚ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ÚalignÚ max_widthÚ min_widthÚ none_formatÚ escape_headerÚ escape_datar©TFTFcSs|Srr)ÚxrrrÚãóz&PrettyTable.__init__..rú|ú-ú+):Úgetr%Ú _field_namesÚ_rowsÚ _dividersrMrArNrOr4r5r6Ú_styleÚ 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_keyÚ _escape_dataÚ_escape_headerrPÚ_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)Úselfr_ÚkwargsÚoptionrrrÚ__init__Es8Ò0                    zPrettyTable.__init__cCsª|t|ƒ}|dkr ||dS|dkr4|d|S|drŠt|ƒdrh|dd||dddS|ddd||ddSn|dd||ddSdS)NÚlú Úrrrr)r‹rrrMÚexcessrrrÚ_justifys     "zPrettyTable._justifycCsP|dkrt|jƒS|dkrD|jr*t|jƒS|jr>t|jdƒSdSnt|ƒ‚dS)NÚrowcountZcolcountr)rr\r[ÚAttributeError)r‹ÚnamerrrÚ __getattr__.s  zPrettyTable.__getattr__cCs tƒ}|j|_|jD]}t|d|t|d|ƒƒqt|dt|dƒƒt|tƒrl|j|D]}| |¡qZn0t|t ƒrˆ| |j|¡nd|›d}t |ƒ‚|S)NÚ_Ú_alignzIndex z( is invalid, must be an integer or slice) r!r_raÚsetattrÚgetattrÚ isinstanceÚslicer\Úadd_rowÚintÚ IndexError)r‹ÚindexÚnewÚattrÚrowÚmsgrrrÚ __getitem__;s    zPrettyTable.__getitem__ÚstrcCs| ¡Sr©Ú get_string©r‹rrrÚ__str__KszPrettyTable.__str__cCs| ¡Srr¨rªrrrÚ__repr__NszPrettyTable.__repr__cCs| ¡S)zs Returns get_html_string value by default as the repr call in Jupyter notebook environment )Úget_html_stringrªrrrÚ _repr_html_QszPrettyTable._repr_html_cCst|dkr| |¡nZ|dkr,| |¡nD|dkrD| ||¡n,|dkr\| ||¡n|dkrr| ||¡nþ|dkrˆ| ||¡nè|dkrž| ||¡nÒ|dkr´| ||¡n¼|d krÊ| ||¡n¦|d krÞ|  |¡n’|d krô|  ||¡n||d kr |  ||¡nd|d krB|  ¡D] \}}| |›d|›|¡qn.|dkrZ|  ||¡n|dkrp| ||¡dS)Nr_rP) r'r(rNrOr7r8r9r:r;r1r-r/r2r3r)) r*r+r,r.rBrCrDrQrRr@r4r5r6Ú.) r<r=r>r?rErFrGrHrIrJrKrLr0)Ú_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Ú formatterrrrrbes>       zPrettyTable._validate_optionc Csþ|jrZzt|ƒt|jƒkst‚Wn8tk rXdt|ƒ›dt|jƒ›d}t|ƒ‚YnX|jr¼zt|ƒt|jdƒks|t‚Wn<tk rºdt|ƒ›dt|jdƒ›d}t|ƒ‚YnXzt|ƒtt|ƒƒksÖt‚Wn tk rød}t|ƒ‚YnXdS)Nz9Field name list has incorrect number of values, (actual) ú!=ú (expected)rzField names must be unique)r[rÚAssertionErrorÚ ValueErrorr\Úset©r‹r¿r¥rrrr°¨s&ÿÿz!PrettyTable._validate_field_namescCs@z|dk rt|tƒst‚Wn tk r:d}t|ƒ‚YnXdS)Nz>Replacement for None value must be a string if being supplied.)rœr§rÄÚ TypeErrorrÇrrrr±Ãs z!PrettyTable._validate_none_formatcCs6z|dkst‚Wn tk r0d}t|ƒ‚YnXdS)N)Úcapr&ÚupperÚlowerNz:Invalid header style, use cap, title, upper, lower or None©rÄrÅrÇrrrr¹Ës z"PrettyTable._validate_header_stylecCs>z|dkst‚Wn(tk r8d|›d}t|ƒ‚YnXdS)N)rÚcr‘ú Alignment z is invalid, use l, c or rrÌrÇrrrÚ_validate_alignÒs  zPrettyTable._validate_aligncCs>z|dkst‚Wn(tk r8d|›d}t|ƒ‚YnXdS)N)ÚtÚmÚbNrÎz is invalid, use t, m, b or NonerÌrÇrrrÚ_validate_valignÙs  zPrettyTable._validate_valigncCsFzt|ƒdkst‚Wn,tk r@d|›d|›}t|ƒ‚YnXdS)NrúInvalid value for ú: )rŸrÄrÅ©r‹r–r¿r¥rrrr²às z%PrettyTable._validate_nonnegative_intcCs>z|dkst‚Wn(tk r8d|›d}t|ƒ‚YnXdS)NrSrÔz. Must be True or False.rÌrÖrrrr¸çs  z#PrettyTable._validate_true_or_falsecCsX|dkr dSzt|tƒst‚| ¡s(t‚Wn(tk rRd|›d}t|ƒ‚YnXdS)NÚrÔz#. Must be an integer format string.)rœr§rÄÚisdigitrÅrÖrrrrºîs z PrettyTable._validate_int_formatcCsÌ|dkr dSz’t|tƒst‚d|ks(t‚| d¡}t|ƒdksBt‚|ddks^|d ¡s^t‚|ddksœ|d ¡sœ|dddkr˜|d d¡ ¡sœt‚Wn(tk rÆd|›d }t|ƒ‚YnXdS) Nr×r¯rrréÿÿÿÿÚfrÔz . Must be a float format string.)rœr§rÄrrrØÚrstriprÅ)r‹r–r¿Úbitsr¥rrrr»øs&   ÿ þýý  z"PrettyTable._validate_float_formatcCs@zt|dƒst‚Wn(tk r:d|›d}t|ƒ‚YnXdS)NÚ__call__rÔz. Must be a function.)ÚhasattrrÄrÅrÖrrrr´ s  zPrettyTable._validate_functioncCsFz|ttttfkst‚Wn(tk r@d|›d}t|ƒ‚YnXdS)NrÔz%. Must be ALL, FRAME, HEADER or NONE.)rnrlÚHEADERÚNONErÄrÅrÖrrrrµs  zPrettyTable._validate_hrulescCsDz|tttfkst‚Wn(tk r>d|›d}t|ƒ‚YnXdS)NrÔz. Must be ALL, FRAME, or NONE.)rnrlràrÄrÅrÖrrrr¶s  zPrettyTable._validate_vrulescCsFz||jks|dkst‚Wn&tk r@d|›}t|ƒ‚YnXdS)NzInvalid field name: )r[rÄrÅrÖrrrr³s  z PrettyTable._validate_field_namecCs@z|D]}| ||¡qWn tk r:d}t|ƒ‚YnXdS)Nz(Fields must be a sequence of field names)r³rÄrÅ)r‹r–r¿rTr¥rrrr·&s z%PrettyTable._validate_all_field_namescCsBzt|ƒdkst‚Wn(tk r<d|›d}t|ƒ‚YnXdS)NrrÔz. Must be a string of length 1.)rrÄrÅrÖrrrr½.s  z!PrettyTable._validate_single_charcCs8zt|tƒst‚Wn tk r2d}t|ƒ‚YnXdS)Nz3Attributes must be a dictionary of name/value pairs)rœÚdictrÄrÈrÖrrrr¾5s z PrettyTable._validate_attributesz list[Any]cCs|jdd…Sr)r\rªrrrÚrows?szPrettyTable.rowsz list[bool]cCs|jdd…Sr)r]rªrrrÚdividersCszPrettyTable.dividersÚboolcCs|jS)z,Print
tags if True,
tags if False)r‰rªrrrrBGszPrettyTable.xhtmlcCs| d|¡||_dS)NrB)rbr‰©r‹r¿rrrrBLs cCs|jSr)rgrªrrrrPQszPrettyTable.none_formatcCsh|jsi|_nV|dks,t|tƒrDt|ƒdkrD|jD]}d|j|<q2n | |¡|jD]}||j|<qTdS©Nr)r[rgrœrárr±©r‹r¿ÚfieldrrrrPUs   cCs|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.)r[rªrrrr_aszPrettyTable.field_namescCsdd„|Dƒ}| d|¡d}|jr2|jdd…}||_|jrˆ|rˆt||ƒD]\}}|j||j|<qL|D]}||jkrj|j |¡qjn*|jr¬|jD]}|jt|j|<q”nd|_|jr|rt||ƒD]\}}|j||j|<qÊ|D]}||jkrè|j |¡qènd|_dS)NcSsg|] }t|ƒ‘qSr©r§©rrTrrrÚ lsz+PrettyTable.field_names..r_rÍrÐ) rbr[r™ÚzipÚpopÚBASE_ALIGN_VALUErMÚ_valignrA)r‹r¿Z old_namesZold_nameÚnew_nameÚ field_namerrrr_js.     cCs|jS)zdControls alignment of fields Arguments: align - alignment, one of "l", "c", or "r" ©r™rªrrrrM†szPrettyTable.aligncCs~|dkst|tƒrHt|ƒdkrH|js0tdi|_qz|jD]}d|j|<q6n2| |¡|jsdt|i|_n|jD]}||j|<qjdS)NrrÍ)rœrárr[rîr™rÏrçrrrrMŽs     cCs|jS)zwControls vertical alignment of fields Arguments: valign - vertical alignment, one of "t", "m", or "b" )rïrªrrrrAžszPrettyTable.valigncCsh|jsi|_nV|dks,t|tƒrDt|ƒdkrD|jD]}d|j|<q2n | |¡|jD]}||j|<qTdS)NrrÐ)r[rïrœrárrÓrçrrrrA¦s   cCs|jS)z^Controls maximum width of fields Arguments: max_width - maximum width integer)Ú _max_widthrªrrrrN²szPrettyTable.max_widthcCsL|dkst|tƒr&t|ƒdkr&i|_n"| d|¡|jD]}||j|<q8dS)NrrN)rœrárrórbr[rçrrrrNºs   cCs|jS)z^Controls minimum width of fields Arguments: min_width - minimum width integer)Ú _min_widthrªrrrrOÃszPrettyTable.min_widthcCsL|dkst|tƒr&t|ƒdkr&i|_n"| d|¡|jD]}||j|<q8dS)NrrO)rœrárrôrbr[rçrrrrOËs   cCs|jSr)rurªrrrr7ÔszPrettyTable.min_table_widthcCs| d|¡||_dS)Nr7)rbrurårrrr7Øs cCs|jSr)rvrªrrrr8ÝszPrettyTable.max_table_widthcCs| d|¡||_dS)Nr8)rbrvrårrrr8ás cCs|jS)z3List or tuple of field names to include in displays)rfrªrrrr)æszPrettyTable.fieldscCs| d|¡||_dS)Nr))rbrfrårrrr)ës cCs|jS)zEOptional table title Arguments: title - table title)rcrªrrrr&ðszPrettyTable.titlecCst|ƒ|_dSr)r§rcrårrrr&ùscCs|jS)z{Start index of the range of rows to print Arguments: start - index of first data row to include in output)rdrªrrrr'ýszPrettyTable.startcCs| d|¡||_dS)Nr')rbrdrårrrr's cCs|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))rerªrrrr( szPrettyTable.endcCs| d|¡||_dS)Nr()rbrerårrrr(s cCs|jS)z_Name of field by which to sort rows Arguments: sortby - field name to sort by)rprªrrrr-szPrettyTable.sortbycCs| d|¡||_dS)Nr-)rbrprårrrr-"s cCs|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)rqrªrrrr.'szPrettyTable.reversesortcCs| d|¡||_dS)Nr.)rbrqrårrrr.1s cCs|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)rrrªrrrr/6szPrettyTable.sort_keycCs| d|¡||_dS)Nr/)rbrrrårrrr/@s cCs|jS)z‹Controls printing of table header with field names Arguments: header - print a header showing field names (True or False))rhrªrrrr*EszPrettyTable.headercCs| d|¡||_dS)Nr*)rbrhrårrrr*Ns cCs|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))rirªrrrr@SszPrettyTable.header_stylecCs| |¡||_dSr)r¹rirårrrr@]s cCs|jS)z~Controls printing of border around table Arguments: border - print a border around the table (True or False))rjrªrrrr+bszPrettyTable.bordercCs| d|¡||_dS)Nr+)rbrjrårrrr+ks cCs|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))rkrªrrrr,psz$PrettyTable.preserve_internal_bordercCs| d|¡||_dS)Nr,)rbrkrårrrr,zs cCs|jS)z˜Controls printing of horizontal rules after rows Arguments: hrules - horizontal rules style. Allowed values: FRAME, ALL, HEADER, NONE)rmrªrrrr2szPrettyTable.hrulescCs| d|¡||_dS)Nr2)rbrmrårrrr2ˆs cCs|jS)z‘Controls printing of vertical rules between columns Arguments: vrules - vertical rules style. Allowed values: FRAME, ALL, NONE)rorªrrrr3szPrettyTable.vrulescCs| d|¡||_dS)Nr3)rbrorårrrr3–s cCs|jS)zbControls formatting of integer data Arguments: int_format - integer format string)Ú _int_formatrªrrrr4›szPrettyTable.int_formatcCsL|dkst|tƒr&t|ƒdkr&i|_n"| d|¡|jD]}||j|<q8dS)Nrr4)rœrárrõrbr[rçrrrr4£s   cCs|jS)zrControls formatting of floating point data Arguments: float_format - floating point format string)Ú _float_formatrªrrrr5¬szPrettyTable.float_formatcCsL|dkst|tƒr&t|ƒdkr&i|_n"| d|¡|jD]}||j|<q8dS)Nrr5)rœrárrörbr[rçrrrr5´s   cCs|jS)z‚Controls formatting of any column using callable Arguments: custom_format - Dictionary of field_name and callable)Ú_custom_formatrªrrrr6½szPrettyTable.custom_formatcCs„|dkri|_npt|tƒrF| ¡D]\}}| d|›|¡q"||_n:t|dƒrt| d|¡|jD]}||j|<qbn d}t|ƒ‚dS)Nz custom_value.rÝZ custom_valuez>The custom_format property need to be a dictionary or callable)r÷rœrár¼r´rÞr[rÈ)r‹r¿rÀÚvrèr¥rrrr6Ås    cCs|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)rwrªrrrr9ÕszPrettyTable.padding_widthcCs| d|¡||_dS)Nr9)rbrwrårrrr9Þs cCs|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)rxrªrrrr:ãszPrettyTable.left_padding_widthcCs| d|¡||_dS)Nr:)rbrxrårrrr:ìs cCs|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)ryrªrrrr;ñszPrettyTable.right_padding_widthcCs| d|¡||_dS)Nr;)rbryrårrrr;ús cCs|jS)z¦The character used when printing table borders to draw vertical lines Arguments: vertical_char - single character string used to draw vertical lines)rzrªrrrr<ÿszPrettyTable.vertical_charcCst|ƒ}| d|¡||_dS)Nr<)r§rbrzrårrrr<s cCs|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ªrrrr=szPrettyTable.horizontal_charcCst|ƒ}| d|¡||_dS)Nr=)r§rbr{rårrrr=s cCs |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…r?rªrrrr>sz!PrettyTable.horizontal_align_charcCst|ƒ}| d|¡||_dS)Nr>)r§rbr|rårrrr>&s cCs|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ªrrrr?,szPrettyTable.junction_charcCst|ƒ}| d|¡||_dS)Nr?)r§rbr}rårrrr?5s cCs |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~r?rªrrrrE;szPrettyTable.top_junction_charcCst|ƒ}| d|¡||_dS)NrE)r§rbr~rårrrrEDs cCs |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)rr?rªrrrrFJsz PrettyTable.bottom_junction_charcCst|ƒ}| d|¡||_dS)NrF)r§rbrrårrrrFTs cCs |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€r?rªrrrrGZszPrettyTable.right_junction_charcCst|ƒ}| d|¡||_dS)NrG)r§rbr€rårrrrGds cCs |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)rr?rªrrrrHjszPrettyTable.left_junction_charcCst|ƒ}| d|¡||_dS)NrH)r§rbrrårrrrHss cCs |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‚r?rªrrrrIys z#PrettyTable.top_right_junction_charcCst|ƒ}| d|¡||_dS)NrI)r§rbr‚rårrrrI„s cCs |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ƒr?rªrrrrJŠs z"PrettyTable.top_left_junction_charcCst|ƒ}| d|¡||_dS)NrJ)r§rbrƒrårrrrJ•s cCs |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„r?rªrrrrK›s z&PrettyTable.bottom_right_junction_charcCst|ƒ}| d|¡||_dS)NrK)r§rbr„rårrrrK¦s cCs |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 junctionsrùrªrrrrL¬s z%PrettyTable.bottom_left_junction_charcCst|ƒ}| d|¡||_dS)NrL)r§rbr…rårrrrL·s cCs|jS)z~Controls whether or not HTML tables are formatted to match styling options Arguments: format - True or False)rˆrªrrrr1½szPrettyTable.formatcCs| d|¡||_dS)Nr1)rbrˆrårrrr1Æs cCs|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ªrrrrCËszPrettyTable.print_emptycCs| d|¡||_dS)NrC)rbr†rårrrrCÕs cCs|jS)z¯A dictionary of HTML attribute name/value pairs to be included in the tag when printing HTML Arguments: attributes - dictionary of attributes)rŠrªrrrr0ÚszPrettyTable.attributescCs| d|¡||_dS)Nr0)rbrŠrårrrr0äs cCs|jS)zs&zPrettyTable._set_default_stylecCs.d|_d|_t|_d|_d|_d|_d|_dS)NTrrW)r*r+ràrmr9r:r;r<rªrrrrÿSszPrettyTable._set_msword_stylecCs"d|_d|_d|_d|_d|_dS)NTFrré)r*r+r9r:r;rªrrrr\s zPrettyTable._set_columns_stylecCsFd|_d|_d|_d|_d|_d|_d|_d|_d |_d |_ d |_ dS) Nuâ•uâ•‘u╬u╦uâ•©uâ•£uâ• uâ•—uâ•”uâ•u╚© r=r<r?rErFrGrHrIrJrKrLrªrrrrcsz$PrettyTable._set_double_border_stylecCsFd|_d|_d|_d|_d|_d|_d|_d|_d |_d |_ d |_ dS) Nu─u│u┼u┬uâ”´u┤u├uâ”u┌u┘uâ””rrªrrrr psz$PrettyTable._set_single_border_stylecCs–ddl}| d¡|_| d¡|_| ttttf¡|_| tttf¡|_ |  dd¡|_ |  dd¡|_ | d¡|_ | d¡|_| d¡|_| d¡|_dS)NrrSéz!~!@#$%^&*()_+|-=\{}[];':\",./;<>?)ÚrandomÚchoicer*r+rnrlrßràrmroÚrandintr:r;r<r=r?r,)r‹rrrrr }s     zPrettyTable._set_random_stylecCs|D]}| |¡qdS)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‹râr¤rrrÚadd_rowsszPrettyTable.add_rowsF)Údivider)rr$cCs||jr.rN) r[rrÅÚranger_r\ÚappendÚlistr])r‹r¤rr¥rrrržšsÿzPrettyTable.add_rowcCsF|t|jƒdkr2d|›dt|jƒ›d}t|ƒ‚|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)rr\r r])r‹Z row_indexr¥rrrÚdel_row­s ÿzPrettyTable.del_rowrÍrÐ)rMrAr$cCsÄt|jƒdt|ƒfkrž| |¡| |¡|j |¡||j|<||j|<tdt|ƒƒD]B}t|jƒ|dkr†|j g¡|j  d¡|j| ||¡qXn"dt|ƒ›dt|jƒ›}t |ƒ‚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 bottomrrFzColumn length z does not match number of rows N) rr\rÏrÓr[rr™rïrr]rÅ)r‹Ú fieldnameÚcolumnrMrAÚir¥rrrÚ add_column½s       ÿzPrettyTable.add_columnÚIndex)rr$cCsN|j d|¡|j|j|<|j|j|<t|jƒD]\}}| d|d¡q0dS)zŽAdd an auto-incrementing index column to the table. Arguments: fieldname - name of the field to contain the new column of datarrN)r[ÚinsertrMr™rArïÚ enumerater\)r‹rr r¤rrrÚ add_autoindexÞs   zPrettyTable.add_autoindexcCsV||jkr,d |d tt|jƒ¡¡}t|ƒ‚|j |¡}|j|=|jD] }||=qFdS)zxDelete a column from the table Arguments: fieldname - The field name of the column you want to delete.zUCan't delete column {!r} which is not a field name of this table. Field names are: {}z, N)r[r1ÚjoinÚmapÚreprrÅr¡r\)r‹rr¥Z col_indexr¤rrrÚ del_columnès þÿ  zPrettyTable.del_columncCsg|_g|_dS)z?Delete all rows from the table but keep the current field namesN)r\r]rªrrrÚ clear_rowsýszPrettyTable.clear_rowscCsg|_g|_g|_g|_dS)z_Delete all rows and field names from the table, maintaining nothing but styling optionsN)r\r]r[r`rªrrrÚclearszPrettyTable.clearcCsddl}| |¡Sræ)ÚcopyÚdeepcopy)r‹r,rrrr,szPrettyTable.copyr)Ú out_formatr$cKs||dkr|jf|ŽS|dkr(|jf|ŽS|dkr<|jf|ŽS|dkrP|jf|ŽS|dkrd|jf|ŽSd|›d}t|ƒ‚dS) 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 latexN)r©r­Úget_json_stringÚget_csv_stringÚget_latex_stringrÅ)r‹r.rŒr¥rrrÚget_formatted_strings      ÿz PrettyTable.get_formatted_stringcCspt|tƒr*||jkr*d|j|›d|St|tƒrT||jkrTd|j|›d|S|j |dd„¡}|||ƒS)Nú%ÚdrÚcSst|ƒSrré)rÚrørrrrU7rVz+PrettyTable._format_value..)rœrŸrõÚfloatrör÷rZ)r‹rèÚvaluerÁrrrÚ _format_value1s zPrettyTable._format_valuecCs~|dtkrd}|dtkr"d}nd}t| |¡ƒ}t|jƒD]:\}}|drb|dr>||dkr>||j||d7}q>|S)Nr3rrrr))rlrnÚsumÚ_get_padding_widthsr$r_r`)r‹rúÚ table_widthÚper_col_paddingr¡rrrrÚ_compute_table_width:s  ÿ ÿz PrettyTable._compute_table_widthcs¦|drdd„|jDƒ}nt|jƒdg}|D]ð}t|ƒD]â\}}|j|}|j |¡dk rx|dksl|dkrx|j |¡}||jkrªt||tt |ƒd|j|ƒƒ||<nt||t |ƒdƒ||<||j kræt|||j |ƒ||<|j t kr:|j |dkrd}nd}t|||ƒ||<q:q.||_t| |¡ƒ‰|jr| |¡} | |jkrˆt|ƒt|ƒd} |j| | | ‰‡fd d„|Dƒ|_|js¢|d r¢|d rØt|d ƒˆ} |d ttfkrÜ| d 7} nd} |jpæd} t| | ƒ}|d r t|ƒd} n|drt|ƒ} nd} |t‡fdd„|Dƒƒ| 8}t|ƒpLd}||kr¢d||‰‡fdd„|Dƒ}t|ƒ|krœ|d|t|ƒ7<||_dS)Nr*cSsg|]}t|ƒd‘qS©r)r ©rrèrrrrëKsz/PrettyTable._compute_widths..rr")rr‘rrcsg|]}tdt|ˆƒƒ‘qS©r)rrŸ©rÚw©Úscalerrrëssr&r3rr+r,csg|]}ˆ‘qSrr)rr˜)r?rrrë‡sgð?csg|]}t|ˆƒ‘qSr)rŸrDrFrrrëŽsrÙ)r[rr_r$rPrZrNrÚminr rOr^rr™r`r<r=rvr@rurlrnr7)r‹rârúÚwidthsr¤r¡r:rrOr>Z markup_charsZ title_widthr7ZbordersZ content_widthr)r?rGrÚ_compute_widthsIsj   þ     ÿ         zPrettyTable._compute_widthscCsD|ddk r|d}n|d}|ddk r4|d}n|d}||fS)Nr:r9r;r)r‹rúÚlpadÚrpadrrrr=“s    zPrettyTable._get_padding_widthscs¨ddl}|dr.| |j|d|d…¡}n | |j¡}|drˆ|j |d¡‰‡fdd„|Dƒ}|j|d |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.rNrDr'r(r-csg|]}|ˆg|‘qSrr©rr¤©Z sortindexrrrë°sz)PrettyTable._get_rows..r.r/)ÚreverseÚkeycSsg|]}|dd…‘qS)rNrrMrrrrë´s)r,r-r\r[r¡Úsort)r‹rúr,rârrNrÚ _get_rowsžs zPrettyTable._get_rowscCsTddl}|dr.| |j|d|d…¡}n | |j¡}|drPdd„|Dƒ}|S) zŠReturn only those dividers that should be printed, based on slicing. Arguments: options - dictionary of option settings.rNrDr'r(r-cSsg|]}d‘qS)Fr)rrrrrrëÊsz-PrettyTable._get_dividers..)r,r-r])r‹rúr,rãrrrÚ _get_dividers¼s zPrettyTable._get_dividerscs‡fdd„tˆj|ƒDƒS)Ncsg|]\}}ˆ ||¡‘qSr)r;)rrèr:rªrrrëÏsÿz+PrettyTable._format_row..©rìr[)r‹r¤rrªrÚ _format_rowÎs  þzPrettyTable._format_rowcs‡fdd„|DƒS)Ncsg|]}ˆ |¡‘qSr)rUrMrªrrrëÕsz,PrettyTable._format_rows..r)r‹rârrªrÚ _format_rowsÔszPrettyTable._format_rowsc KsÞ| |¡}g}|jdkr,|dr(|ds,dS| |¡}| |¡}| |¡}| ||¡| |¡|_|dpn|j}|r†|  |  ||¡¡|dr |  |  |¡¡nh|dr|dt t fkr|  |j|dd ¡|r|d t t fkr|j|d d d …|j|d <t|d d …|d d …ƒD]:\}} |  | |||j¡¡| r"|  |j|dd ¡q"|r†|  | |d ||j|dd ¡¡|dr²|dt kr²|  |j|dd ¡d|jkrÔ|jrÔdd„|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 stringrrCr+r×r&r*r2Útop_©Úwherer3rÙrNZbottom_rcSs0g|](}| d¡D]}d|dd…d‘qqS)rrWrrÙ)r)rZold_lineÚnew_linerrrrëAs þz*PrettyTable.get_string..r)rûr”rRrSrVrJÚ_stringify_hruleÚ_hrulercrÚ_stringify_titleÚ_stringify_headerrnrlrHrGrìÚ_stringify_rowÚ__dict__rr&) r‹rŒrúrrârãÚformatted_rowsr&r¤rrrrr©ÛsL0      ÿ" ýÿ þzPrettyTable.get_stringr×rXc CsŽ|ds|dsdS| |¡\}}|dttfkrB||dg}n |dg}|jsn| ||d¡d |¡St|j|jƒD]º\}}|drš||dkršq|||||d}|jrü|j |d krØd |j|d d…}|j |d krü|dd …|jd }| |¡|dtkr(| ||d¡q|| |d¡q||dttfkrd|  ¡| ||d¡|dr„|ds„|dd…}d |¡S)Nr+r,r×r3rHr=rGr))rrÍrr)rÍr‘éþÿÿÿr?rrÙ) r=rnrlr[rr&rìr`r|r™rí) r‹rúrYrKrLrÜrèrrrrrr[Is8    zPrettyTable._stringify_hrulecsg}| |¡\‰‰|drh|dtkrJt|d<| | |d¡¡t|d<n|dtkrh| | |d¡¡g}|dttfkrŒ|drŒ|dnd}| |¡dˆ|dˆ}| |¡\‰‰t‡‡fdd„|jDƒƒ}| | ||dd ¡¡| |¡| d  |¡¡d  |¡S) Nr+r3rWr<rcsg|]}|ˆˆd‘qSrCrr©rKrLrrrëƒsz0PrettyTable._stringify_title..rrÍr×r) r=rnrlrr[r<r`r“r&)r‹r&rúrrÜZendpointZ sum_widthsrrcrr]ps0   ÿÿ ý  zPrettyTable._stringify_titlec Csg}| |¡\}}|dr¾|dttfkr”| | |d¡¡|drŠ|dttfkrŠt|jƒ}t|jƒ}|j|d|| …|j|d<| d¡|dttfkr´| |d¡n | d ¡|jsî|dttfkrä| |d¡n | d ¡t |j|j ƒD]ü\}}|d r||d krqü|j d kr4|  ¡} nF|j dkrJ|  ¡} n0|j d kr`| ¡} n|j d krv| ¡} n|} t| ƒ|kr”| d|…} | d || | ||j|¡d |¡|dsÐ|drü|dtkrî| |d¡qü| d ¡qü|ds |dr | ¡| d ¡|drN|dtkrN| ¡| |d¡|dsb|dr†|dtkr†| d¡| |j¡d |¡S)Nr+r2rWr&r3rÙrr<rr)rÉrÊrËr,r×)r=rnrlrr[rrHrGr[rìr`riÚ capitalizer&rÊrËrr“r™ríràr\r&) r‹rúrÜrKrLZ left_j_lenZ right_j_lenrèrrrrrr^Šsz  ÿþÿ            ÿþÿ  ÿþ  zPrettyTable._stringify_headerc CsZddl}ttdt|ƒƒ|j||jƒD]~\}}}}| d¡} g} | D]H} | dkrh|j |¡dk rh|j|} t | ƒ|kr€|  | |¡} |   | ¡qB| } d  | ¡}|||<q$d} |D]} t | ƒd}|| kr¬|} q¬g}| |¡\}}td| ƒD]H}|  g¡|dræ|dttfkr ||  |j¡qæ||  d¡qæt|j||jƒD]6\}}}|j|}| d¡} | t| ƒ}|rÒ|dkrªd gt|d ƒ| d g|t|d ƒ} n(|d krÄd g|| } n| d g|} d}| D]š} |d rú||d krúqÚ||  d|| | ||j|¡d|¡|ds<|d rj|dtkr\||  |j¡n||  d¡|d7}qÚq@|ds¨|d r¨|d ¡|d  d¡td| ƒD]<}|dr²|dtkr²|| ¡||  |d¡q²|dr,|dtkr,|| d  d¡|| d  |¡td| ƒD]}d   ||¡||<q6d  |¡S)Nrrr"rr+r3rrÑr×rrÒr)r,rÙr<r2)Útextwraprìrrr[r`rrPrZrÚfillrr&r r=rnrlr<rïrŸr“r™rí)r‹r¤rúZhrulerer¡rèr:rrÚ new_linesrÚ row_heightrÍÚhrÜrKrLÚyrAZd_heightrrrr_Îs– ÿ             ÿþÿ ÿþÿ  zPrettyTable._stringify_rowé:ú rŸ)Ú page_lengthÚ line_breakcKstg}| dd¡|d<| d|j¡}t|d||ƒ|d<| |jf|Ž¡|d|krXqj|d|7<q"| |¡S)Nr'rr()rZr”rHrr©r&)r‹rmrnrŒZpagesZtrue_endrrrÚpaginate(s zPrettyTable.paginatec sºddl}ˆ |¡‰‡fdd„| ¡Dƒ}t ¡}|j|f|Ž}ˆ d¡rxˆdrl| ‡fdd„ˆjDƒ¡n | ˆj¡ˆ  ˆ¡}ˆdrž‡‡fd d„|Dƒ}|D]}| |¡q¢|  ¡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. rNcsi|]\}}|ˆkr||“qSrr©rrPr:©rúrrÚ Csz.PrettyTable.get_csv_string..r*r)csg|]}|ˆdkr|‘qS©r)r©rrÚrqrrrëLs z.PrettyTable.get_csv_string..cs&g|]}‡fdd„tˆj|ƒDƒ‘qS)cs g|]\}}|ˆdkr|‘qSrsr©rrÚr8rqrrrëTs z9PrettyTable.get_csv_string...rTrM©rúr‹rrrëSsÿ) r1rûr¼ÚioÚStringIOÚwriterrZÚwriterowr[rRÚgetvalue)r‹rŒr1Z csv_optionsZ csv_bufferZ csv_writerrâr¤rrvrr47s*   ÿ ÿ   þ zPrettyTable.get_csv_stringc säddl}| |¡‰ddddœ}| ‡fdd„| ¡Dƒ¡g}ˆ d ¡rxˆd rl| ‡fd d „|jDƒ¡n | |j¡| ˆ¡}ˆd r¶|D]$}| ‡fd d„t |j|ƒDƒ¡qŽn |D]}| t t |j|ƒƒ¡qº|j |f|Ž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. rNé)ú,rÕT)ÚindentÚ separatorsÚ sort_keyscsi|]\}}|ˆkr||“qSrrrprqrrrrmsz/PrettyTable.get_json_string..r*r)csg|]}|ˆdkr|‘qSrsrrtrqrrrëss z/PrettyTable.get_json_string..cs"i|]\}}|ˆdkr||“qSrsrrurqrrrrzs þ) r0rûÚupdater¼rZrr[r_rRrìráÚdumps)r‹rŒr0Z json_optionsÚobjectsrâr¤rrqrr3_s,   ÿ     þÿzPrettyTable.get_json_stringcKs,| |¡}|dr| |¡}n | |¡}|S)aeReturn 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) escape_header - escapes the text within a header (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
tag format - Controls whether or not HTML tables are formatted to match styling options (True or False) escape_data - escapes the text within a data field (True or False) xhtml - print
tags if True,
tags if Falser1)rûÚ_get_formatted_html_stringÚ_get_simple_html_string©r‹rŒrúÚstringrrrr­Šs #   zPrettyTable.get_html_stringc CsÞddlm}g}|drd}nd}dg}|drf|dD],}| d||ƒ›d ||d|ƒ›d ¡q8| d ¡| d  |¡¡|d pŒ|j}|r¨| d||ƒ›d¡|dr$| d¡| d¡|jD]B}|dræ||dkræqÌ|drö||ƒ}| d | d|¡¡¡qÌ| d¡| d¡| d¡| |¡} |  | ¡} | D]x} | d¡t |j| ƒD]P\}} |dr„||dkr„q`|dr–|| ƒ} | d |  d|¡¡¡q`| d¡qF| d¡| d¡d |¡S)Nr©ÚescaperBú
ú
úr×r&ú r*ú ú r)rQz rú ú ú rRz ú ú
ú
{}
{}
) r/r‰rr&rcr[r1ÚreplacerRrVrì) r‹rúr‰rÚ linebreakÚopen_tagÚ attr_namer&rèrârar¤Údatumrrrr…¶s\   ÿ     ÿ       ÿ  z#PrettyTable._get_simple_html_stringc CsTddlm}g}| |¡\}}|dr,d}nd}dg}|dr |dtkrd|d tkrd| d ¡n¨|dtkrˆ|d tkrˆ| d ¡n„|dtkr¬|d tkr¬| d ¡n`|dtkrÄ| d ¡nH|dtkrÜ| d¡n0|d tkrô| d¡n|d tkr | d¡|ds*|dr*| d¡|drl|dD].}| d||ƒ›d||d|ƒ›d¡q<| d¡| d |¡¡|dp”|j} | r²| d|| ƒ›d¡|dr<| d¡| d¡|jD]P} |drö| |dkröqÖ|d r|| ƒ} | d!|||   d"|¡f¡qÖ| d#¡| d$¡| d%¡|  |¡} |  | ¡} g} g}|jD]>} |  d&d'd(d)œ|j | ¡| d*d+d,d-œ|j | ¡qh| D]ˆ}| d¡t|j|| |ƒD]\\} }}}|drò| |dkròqÊ|d.r||ƒ}| d/|||||  d"|¡f¡qÊ| d#¡q¬| d0¡| d1¡d" |¡S)2NrrˆrBrŠr‹rŒr+r2r3z 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,z rules="cols"r0rrrŽrr×r&rr‘r*r’r“r)rQz[ %srr”r•r–ÚleftÚrightÚcenter)rr‘rÍÚtopÚmiddleÚbottom)rÐrÑrÒrRzk %sr—r˜)r/r‰r=rnrrlr&rcr[r™rRrVr™rïrì)r‹rúr‰rrKrLršr›rœr&rèrâraZalignsZvalignsr¤rrMrArrrr„ós®                ÿ      ÿÿ      ÿÿ ÿ  ûÿÿ   z&PrettyTable._get_formatted_html_stringcKs,| |¡}|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) r1)rûÚ_get_formatted_latex_stringÚ_get_simple_latex_stringr†rrrr5X s    zPrettyTable.get_latex_stringc sÖg}g‰ˆdr&‡fdd„ˆjDƒ‰nˆj‰d ‡fdd„ˆDƒ¡}d|›d}| |¡ˆdrv| d  ˆ¡d ¡ˆ ˆ¡}ˆ |¡}|D]2}‡fd d„tˆj|ƒDƒ}| d  |¡d ¡qŽ| d ¡d  |¡S)Nr)csg|]}|ˆdkr|‘qSrsrrBrqrrrë} s z8PrettyTable._get_simple_latex_string..r×csg|]}ˆj|‘qSrròrBrªrrrëƒ sú\begin{tabular}{Ú}r*ú & ú \\csg|]\}}|ˆkr|‘qSrrru©Ú wanted_fieldsrrrë sú \end{tabular}ú )r[r&rrRrVrì) r‹rúrZ alignmentsÚ begin_cmdrârar¤Ú wanted_datar©rúr‹r«rr¥x s* ÿ      ÿ z$PrettyTable._get_simple_latex_stringc sÜg}g‰ˆdr&‡fdd„ˆjDƒ‰nˆj‰‡fdd„ˆDƒ}ˆdr^ˆdtkr^d |¡}n&ˆdszˆdrzd |¡}n d  |¡}ˆdr¨ˆdttfkr¨d|d}d |›d }| |¡ˆdràˆd ttfkrà| d ¡ˆdrü| d ˆ¡d¡ˆdsˆdr,ˆd ttfkr,| d ¡ˆ ˆ¡}ˆ |¡}ˆ ˆ¡}|D]V}‡fdd„tˆj|ƒDƒ} | d | ¡d¡ˆdrNˆd tkrN| d ¡qNˆdrȈd tkrÈ| d ¡| d¡d |¡S)Nr)csg|]}|ˆdkr|‘qSrsrrBrqrrrëž s z;PrettyTable._get_formatted_latex_string..csg|]}ˆj|‘qSrròrBrªrrrë¤ sr+r3rWr,r×r¦r§r2z\hliner*r¨r©csg|]\}}|ˆkr|‘qSrrrurªrrrëÁ sr¬r­) r[rnr&rlrrßrRrVrì) r‹rúrZwanted_alignmentsZ alignment_strr®rârar¤r¯rr°rr¤™ sR ÿ       ÿþ      ÿ  z'PrettyTable._get_formatted_latex_string)N)rÍrÐ)r")r)r×)rkrl)wÚ__name__Ú __module__Ú __qualname__rŽr“r—r¦r«r¬r®rbr°r±r¹rÏrÓr²r¸rºr»r´rµr¶r³r·r½r¾ÚpropertyrârãrBÚsetterrPr_rMrArNrOr7r8r)r&r'r(r-r.r/r*r@r+r,r2r3r4r5r6r9r:r;r<r=r>r?rErFrGrHrIrJrKrLr1rCr0rDrQrRrûr rrrýrÿrrr r rržrr!r%r)r*r+r,r6r;r@rJr=rRrSrUrVr©r[r]r^r_ror4r3r­r…r„r5r¥r¤rrrrr!DsU C                                                         ÿ!   J    n'  D Z(+, = e !r!cCsddl}| t d|¡¡S)Nrr×)ÚwcwidthZwcswidthÚ_reÚsub)r¿r¶rrrrÕ srz Any | None)r_c Ks¶ddl}i}dD]}||kr| |¡||<q|r@|j|f|Ž}n*| ¡ | d¡¡}| d¡| ||¡}tf|Ž}|r€||_ndd„t |ƒDƒ|_|D]} |  dd„| Dƒ¡q˜|S)Nr)Ú delimiterÚ doublequoteÚ escapecharÚlineterminatorÚ quotecharÚquotingÚskipinitialspaceÚstricticSsg|] }| ¡‘qSr©Ústriprêrrrrëû szfrom_csv..cSsg|] }| ¡‘qSrrÁrêrrrrëþ s) r1ríÚreaderÚSnifferÚsniffÚreadÚseekr!r_Únextrž) Úfpr_rŒr1Z fmtparamsÚparamrÃÚdialectÚtabler¤rrrÚfrom_csvà s"    rÍcKsB|jr>tf|Ž}dd„|jDƒ|_| ¡D]}| |¡q*|SdS)NcSsg|] }|d‘qSrAr)rÚcolrrrrë sz"from_db_cursor..)Ú descriptionr!r_Zfetchallrž)ÚcursorrŒrÌr¤rrrÚfrom_db_cursor s    rÑc sZddl}tf|Ž}| |¡}|d|_|dd…D]"‰‡fdd„|jDƒ}| |¡q2|S)Nrrcsg|] }ˆ|‘qSrr)rrP©Úobjrrrë szfrom_json..)r0r!Úloadsr_rž)Z json_stringrŒr0rÌrƒr¤rrÒrÚ from_json s    rÕc@sZeZdZddœdd„Zddœdd„Zddœdd„Zddœd d „Zd d „Zddœd d„ZdS)Ú TableHandlerr"r#cKsDt |¡||_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ŒrrrrŽ s zTableHandler.__init__cCs8||_|dkrd|_|D]\}}|dkrt|ƒ|_qdS)NÚthTrÝ)rÚrÜrŸrÝ)r‹ÚtagÚattrsrPr:rrrÚhandle_starttag% s  zTableHandler.handle_starttagcCsº|dkrH|j ¡}|j |¡|jrHtd|jƒD]}|j d¡q0d|_|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ØrrÝrrârÜrrÙrÚgenerate_tabler×rÚ)r‹rßZstripped_contentr rÌrrrÚ handle_endtag- s$    zTableHandler.handle_endtagcCs|j|7_dSr)rÛ)r‹ÚdatarrrÚ handle_dataB szTableHandler.handle_datacCsŽtf|jŽ}|jD]v}t|dƒ|jkrX|jt|dƒ}td|ƒD]}|d d¡qD|drz| |d¡|d|_q|  |d¡q|S)zE Generates from a list of rows a PrettyTable object. rrrX) r!rŒrârrÙrrÚmake_fields_uniquer_rž)r‹rârÌr¤Úappendsr rrrräE s   zTableHandler.generate_tablecCsPtdt|ƒƒD]<}t|dt|ƒƒD]$}||||kr$||d7<q$qdS)zB iterates over the row and make each field unique rrú'N)rr)r‹r)r ÚjrrrrèW szTableHandler.make_fields_uniqueN) r±r²r³rŽrárårçrärèrrrrrÖ s  rÖcKstf|Ž}| |¡|jS)zƒ Generates a list of PrettyTables from a string of HTML code. Each in the HTML becomes one PrettyTable object. )rÖÚfeedr×)Ú html_coderŒÚparserrrrÚ from_htmla s  rïcKsJt|f|Ž}zt|ƒdkst‚Wn tk r@d}t|ƒ‚YnX|dS)zf Generates a PrettyTables from a string of HTML code which contains only a single
rzCMore than one
in provided HTML code. Use from_html instead.r)rïrrÄrÅ)rírŒr×r¥rrrÚ from_html_onel s rð)N) Ú __future__rrwÚreÚ html.parserrÚtypingrrlrnràrßrürþrrrrrr rîÚcompiler·r r!rrÍrÑrÕrÖrïrðrrrrÚ"s\    $ #  I