F`Qc@sdZddlZddlZddlZddlZddlZddlZddlZddlZej ddkZ e re Z e Z eZeZeZddlmZn(ejZejZeZddlmZe oej ddkrddlmZnddlmZdZdZdZdZd Z d Z!d Z"d Z#ej$d Z%dZ&de'fdYZ(dZ)dZ*e+dZ,dZ-defdYZ.dZ/dZ0dZ1e2dkre1ndS(s0.7.2iNii(t HTMLParserii(tescapei i i is \[[0-9;]*mcCsJ|jd}t|}tg|D]}t|^q%}||fS(Ns (tsplittlentmaxt_str_block_width(ttexttlinestheighttlinetwidth((s//usr/lib/python2.7/site-packages/prettytable.pyt _get_sizeLs %t PrettyTablecBs-eZdgdZdZdZdZdZerHdZ n dZ dZ dZ d Z d Z d Zd Zd ZdZdZdZdZdZdZdZdZdZdZdZdZeeeZdZdZ eee Z!dZ"dZ#ee"e#Z$dZ%dZ&ee%e&Z'd Z(d!Z)ee(e)Z*d"Z+d#Z,ee+e,Z-d$Z.d%Z/ee.e/Z0d&Z1d'Z2ee1e2Z3d(Z4d)Z5ee4e5Z6d*Z7d+Z8ee7e8Z9d,Z:d-Z;ee:e;Z<d.Z=d/Z>ee=e>Z?d0Z@d1ZAee@eAZBd2ZCd3ZDeeCeDZEd4ZFd5ZGeeFeGZHd6ZId7ZJeeIeJZKd8ZLd9ZMeeLeMZNd:ZOd;ZPeeOePZQd<ZRd=ZSeeReSZTd>ZUd?ZVeeUeVZWd@ZXdAZYeeXeYZZdBZ[dCZ\ee[e\Z]dDZ^dEZ_ee^e_Z`dFZadGZbeeaebZcdHZddIZeeedeeZfdJZgdKZheegehZidLZjdMZkdNZldOZmdPZndQZodRZpdSZqdTdUdVZrdWZsdXZtdYZudZZvd[Zwd\Zxd]Zyd^Zzd_Z{d`Z|daZ}dbZ~dcZddZdeZdfZRS(hcKs |jdd|_g|_i|_i|_i|_g|_|rT||_n g|_dj |_ |j j dj |j j dj x>|j D]3}||kr|j |||qd#||st int_formatt float_formatt padding_widthitleft_padding_widthtright_padding_widtht vertical_chart|thorizontal_chart-t junction_chart+t print_emptytformattxhtmlt attributesN(*tgetR t _field_namest_alignt_valignt _max_widtht_rowst field_namest_widthsRt_optionstextendt_validate_optiontNonet_startt_endt_fieldstTruetFalset_headert _header_stylet_bordertFRAMEt_hrulestALLt_vrulest_sortbyt _reversesortt _sort_keyt _int_formatt _float_formatt_padding_widtht_left_padding_widtht_right_padding_widtht_unicodet_vertical_chart_horizontal_chart_junction_chart _print_emptyt_formatt_xhtmlt _attributes(tselfR0tkwargstoption((s//usr/lib/python2.7/site-packages/prettytable.pyt__init__Ts^            cCsIt|tst|}nt|tsEt||jd}n|S(Ntstrict(t isinstancet basestringtstrtunicodeR (RRtvalue((s//usr/lib/python2.7/site-packages/prettytable.pyRJs cCs|t|}|dkr(||dS|dkr@|d|S|drt|drz|dd||dddS|ddd||ddSn|dd||ddSdS(Ntlt trii(R(RRRR taligntexcess((s//usr/lib/python2.7/site-packages/prettytable.pyt_justifys      #cCsl|dkrt|jS|dkr\|jr;t|jS|jrUt|jdSdSn t|dS(Ntrowcounttcolcounti(RR/R+tAttributeError(RRtname((s//usr/lib/python2.7/site-packages/prettytable.pyt __getattr__s      cCst}|j|_x2|jD]'}t|d|t|d|qWt|dt|dt|trxa|j|D]}|j|qWn<t|t r|j|j|nt dt ||S(Nt_R,s0Index %s is invalid, must be an integer or slice( R R0R2tsetattrtgetattrRWtsliceR/tadd_rowtintt ExceptionRY(RRtindextnewtattrtrow((s//usr/lib/python2.7/site-packages/prettytable.pyt __getitem__s  %cCs |jS(N(t __unicode__(RR((s//usr/lib/python2.7/site-packages/prettytable.pyt__str__scCs|jj|jS(N(RstencodeR (RR((s//usr/lib/python2.7/site-packages/prettytable.pyRtscCs |jS(N(t get_string(RR((s//usr/lib/python2.7/site-packages/prettytable.pyRsscCs|dkr|j|n|dkr;|j||nb|d krZ|j||nC|d kry|j||n$|d kr|j||n|d kr|j||n|d kr|j||n|dkr|j||n|dkr|j|n|dkr0|j ||nm|dkrO|j ||nN|dkrn|j ||n/|dkr|j ||nt d|dS(NR0RRt max_widthRRRR'RRRRRRRRR(R&RRRR R"R$R)sUnrecognised option: %s!(sstartsends max_widths padding_widthsleft_padding_widthsright_padding_widthsformat(sheadersborders reversesortsxhtmls print_empty(s vertical_charshorizontal_chars junction_char(t_validate_field_namest_validate_nonnegative_intt_validate_field_namet_validate_functiont_validate_hrulest_validate_vrulest_validate_all_field_namest_validate_true_or_falset_validate_header_stylet_validate_int_formatt_validate_float_formatt_validate_single_chart_validate_attributesRm(RRRTtval((s//usr/lib/python2.7/site-packages/prettytable.pyR4s6             cCs|jrIyWqItk rEtdt|t|jfqIXn|jryWqtk rtdt|t|jdfqXnyWntk rtdnXdS(NsJField name list has incorrect number of values, (actual) %d!=%d (expected)isField names must be unique!(R+tAssertionErrorRmRR/(RRR((s//usr/lib/python2.7/site-packages/prettytable.pyRxs  ,  0 cCs(yWntk r#tdnXdS(Ns;Invalid header style, use cap, title, upper, lower or None!(RRm(RRR((s//usr/lib/python2.7/site-packages/prettytable.pyR0s cCs,yWn!tk r'td|nXdS(Ns'Alignment %s is invalid, use l, c or r!(RRm(RRR((s//usr/lib/python2.7/site-packages/prettytable.pyt_validate_align6s cCs,yWn!tk r'td|nXdS(Ns-Alignment %s is invalid, use t, m, b or None!(RRm(RRR((s//usr/lib/python2.7/site-packages/prettytable.pyt_validate_valign<s cCs;yWn0tk r6td||j|fnXdS(NsInvalid value for %s: %s!(RRmRJ(RRReR((s//usr/lib/python2.7/site-packages/prettytable.pyRyBs cCs,yWn!tk r'td|nXdS(Ns-Invalid value for %s! Must be True or False.(RRm(RRReR((s//usr/lib/python2.7/site-packages/prettytable.pyRHs cCs<|dkrdSyWn!tk r7td|nXdS(Nts8Invalid value for %s! Must be an integer format string.(RRm(RRReR((s//usr/lib/python2.7/site-packages/prettytable.pyRNs   cCsK|dkrdSy|jd}Wn!tk rFtd|nXdS(NRt.s5Invalid value for %s! Must be a float format string.(RRRm(RRReRtbits((s//usr/lib/python2.7/site-packages/prettytable.pyRWs  cCs,yWn!tk r'td|nXdS(Ns*Invalid value for %s! Must be a function.(RRm(RRReR((s//usr/lib/python2.7/site-packages/prettytable.pyR{ds cCs,yWn!tk r'td|nXdS(Ns:Invalid value for %s! Must be ALL, FRAME, HEADER or NONE.(RRm(RRReR((s//usr/lib/python2.7/site-packages/prettytable.pyR|js cCs,yWn!tk r'td|nXdS(Ns3Invalid value for %s! Must be ALL, FRAME, or NONE.(RRm(RRReR((s//usr/lib/python2.7/site-packages/prettytable.pyR}ps cCs,yWn!tk r'td|nXdS(NsInvalid field name: %s!(RRm(RRReR((s//usr/lib/python2.7/site-packages/prettytable.pyRzvs cCsIy%x|D]}|j||q WWntk rDtdnXdS(Ns)fields must be a sequence of field names!(RzRRm(RRReRR((s//usr/lib/python2.7/site-packages/prettytable.pyR~|s   cCs,yWn!tk r'td|nXdS(Ns4Invalid value for %s! Must be a string of length 1.(RRm(RRReR((s//usr/lib/python2.7/site-packages/prettytable.pyRs cCs(yWntk r#tdnXdS(Ns4attributes must be a dictionary of name/value pairs!(RRm(RRReR((s//usr/lib/python2.7/site-packages/prettytable.pyRs cCs|jS(N(R+(RR((s//usr/lib/python2.7/site-packages/prettytable.pyt_get_field_namesscCsg|D]}|j|^q}|jd||jrH|j}n||_|jr|rx1t||D] \}}|j||j| tag when printing HTML Arguments: attributes - dictionary of attributes(RQ(RR((s//usr/lib/python2.7/site-packages/prettytable.pyt_get_attributesscCs|jd|||_dS(NR)(R4RQ(RRR((s//usr/lib/python2.7/site-packages/prettytable.pyt_set_attributesscCsfi}xY|jD]N}||krG|j||||||||tkrK|jn%|tkrd|jn tddS(NsInvalid pre-set style!( tDEFAULTt_set_default_styletMSWORD_FRIENDLYt_set_msword_stylet PLAIN_COLUMNSt_set_columns_styletRANDOMt_set_random_styleRm(RRtstyle((s//usr/lib/python2.7/site-packages/prettytable.pyt set_styles        cCs^t|_t|_t|_t|_d|_d|_d|_ d|_ d|_ d|_ dS(NiR!R#R%( R9RRR>R?R@RARRRR R"R$(RR((s//usr/lib/python2.7/site-packages/prettytable.pyRs         cCsCt|_t|_t|_d|_d|_d|_d|_dS(NiR!( R9RRtNONER?RRRR (RR((s//usr/lib/python2.7/site-packages/prettytable.pyRs      cCs1t|_t|_d|_d|_d|_dS(Niii(R9RR:RRRR(RR((s//usr/lib/python2.7/site-packages/prettytable.pyRs     cCstjttf|_tjttf|_tjtttt f|_ tjttt f|_ tj dd|_ tj dd|_tjd|_tjd|_tjd|_dS(Niis ~!@#$%^&*()_+|-=\{}[];':",./;<>?(trandomtchoiceR9R:RRR@R>tHEADERRR?RAtrandintRRR R"R$(RR((s//usr/lib/python2.7/site-packages/prettytable.pyRscCs|jrLt|t|jkrLtdt|t|jfn|jsgtdt|D]}d|d^qk|_n|jjt|dS(sAdd a row to the table Arguments: row - row of data, should be a list with as many elements as the table has fieldss>Row has incorrect number of values, (actual) %d!=%d (expected)isField %diN(R+RRmtrangeR0R/tappendtlist(RRRqtn((s//usr/lib/python2.7/site-packages/prettytable.pyRk(s $( 6cCsI|t|jdkr;td|t|jfn|j|=dS(sDelete a row to the table Arguments: row_index - The index of the row you want to delete. Indexing starts at 0.is4Cant delete row at index %d, table only has %d rows!N(RR/Rm(RRt row_index((s//usr/lib/python2.7/site-packages/prettytable.pytdel_row7s"RRcCst|jdt|fkr|j||j||jj|||j|<||j||d s:|d r>dS|j|}|j||}|j|||j||_|dr|j|j|n3|dr|dt t fkr|j|jnx'|D]}|j|j ||qW|dr.|dt kr.|j|jn|j dj |S(s"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 iR&RRRRs (RRbRRRt_stringify_hrulet_hruleRt_stringify_headerR@R>t_stringify_rowRJtjoin(RRRSRRRtformatted_rowsRq((s//usr/lib/python2.7/site-packages/prettytable.pyRvs"%   cCsP|dsdS|j|\}}|dttfkrI|dg}n |dg}|js}|j|ddj|Sxt|j|jD]~\}}|dr||dkrqn|j||||d|dtkr|j|dq|j|dqW|dtkrC|j|j|dndj|S(NRRRR$R"R( RR@R>R+RRRR1R(RRRRRRRR ((s//usr/lib/python2.7/site-packages/prettytable.pyRs(    " c Csg}|j|\}}|dr|dttfkr[|j|j|jdn|dttfkr|j|dq|jdn|js|dttfkr|j|dq|jdnx2t|j|jD]\}}|dr||dkrqn|jdkr8|j }n`|jd krV|j }nB|jd krt|j }n$|jd kr|j }n|}|jd||j |||j|d||dr|dtkr|j|dq |jdqqW|drE|dtkrE|j|j|dn|dr|dtkr|jd|j|jnd j|S( NRRs RR R]RtcapttitletuppertlowerR(RR@R>RRR+RR1R<t capitalizeRRRRaR,RRR(RRRRRRRR R((s//usr/lib/python2.7/site-packages/prettytable.pyR sJ  "3   c Csxttdt||j||jD]\}}}}|jd}g}xB|D]:} t| |krtj| |} n|j | qYW|}dj |}|||R R-RlRaR,RR(RRRqRRnRR[R Rt new_linesR t row_heightRthRRRtyRtdHeightR\((s//usr/lib/python2.7/site-packages/prettytable.pyR:sj=      (  7  7 cKs>|j|}|dr+|j|}n|j|}|S(s;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 tag xhtml - print
tags if True,
tags if falseR'(Rt_get_formatted_html_stringt_get_simple_html_string(RRRSRtstring((s//usr/lib/python2.7/site-packages/prettytable.pytget_html_strings  c Csg}|drd}nd}g}|jd|drsx4|dD]%}|jd||d|fqGWn|jd|jdj||d r|jd xT|jD]I}|d r||d krqn|jd t|jd |qW|jdn|j|}|j||}x|D]} |jd xct|j| D]O\}} |d r||d krqbn|jdt| jd |qbW|jdq<W|jd|jd j|S(NR(s
s
sRRs Rs s s s s
%s
%s
( RRR+RtreplaceRRRRJ( RRRRt linebreaktopen_tagt attr_nameRRRRqtdatum((s//usr/lib/python2.7/site-packages/prettytable.pyRs:    &   '  ' cCsg}|j|\}}|dr.d}nd}g}|jd|drd|dtkr|dtkr|jdqd|dtkr|dtkr|jd qd|dtkr|dtkr|jd qd|dtkr|jd qd|dtkr!|jd qd|dtkrA|jd qd|dtkrd|jdqdn|drx4|dD]%}|jd||d|fqyWn|jd|jdj||drO|jdx]|jD]R}|dr||dkrqn|jd||t|jd|fqW|jdn|j|} |j | |} g} g} xk|jD]`}| jidd6dd6dd6|j || jidd 6d!d"6d#d$6|j |qWx| D]} |jdx~t |j| | | D]d\}}}}|drO||dkrOqn|jd%||||t|jd|fqW|jdqW|jd&|j dj|S('NR(s
s
sRsW %ss s tleftR\trightR^tcenterRttopRtmiddleRtbottomRsg %ss(RRR@R>RR+RRRRR,R-RRJ(RRRRRRRRRRRRtalignstvalignsRqRR_R((s//usr/lib/python2.7/site-packages/prettytable.pyR sd        &   0-1  +6 N(t__name__t __module__R5RURJRaRfRrtpy3kRtRsR4RxRRRRyRRRR{R|R}RzR~RRRRtpropertyR0RRR_RRRRRRwRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR RRR"RRR$RRR'RRR&RRR)RRRRRRRkRRRRRRRRRRRRvRRRRRR (((s//usr/lib/python2.7/site-packages/prettytable.pyR Rs ]                                                                                     =  / L (c Csd|kodknr dSd|ko7dknr@dSd|koWdknr`dStjt|ryd Sd |kod knsd |kod knrdSd|kodknrdSd|kodknrdS|dkrdS|dkrd SdS(Ni!i~iiNiiiiii@0i0i0i0ii`i0i>0iiii(ii(ii(t unicodedatat combiningtuni_chr(tchar((s//usr/lib/python2.7/site-packages/prettytable.pyt_char_block_widths&8  cCs(ttttttjd|S(NR(tsumtitermapR'tordt_retsub(R((s//usr/lib/python2.7/site-packages/prettytable.pyR/scKstjj|jd}|jdtj||}t|}|r[||_nYtrgt |D]}|j ^qn|_n(g|j D]}|j ^q|_x4|D],}|j g|D]}|j ^qqW|S(Nii( tcsvtSniffertsnifftreadtseektreaderR R0R!tnexttstripRk(tfpR0RStdialectR2ttableRRq((s//usr/lib/python2.7/site-packages/prettytable.pytfrom_csv7s   +( *cKsd|jr`t|}g|jD]}|d^q|_x!|jD]}|j|qEW|SdS(Ni(t descriptionR R0tfetchallRk(tcursorRSR7tcolRq((s//usr/lib/python2.7/site-packages/prettytable.pytfrom_db_cursorKs   #t TableHandlercBs>eZdZdZdZdZdZdZRS(cKsYtj|||_g|_g|_g|_d|_d|_d|_ t |_ dS(NiR( RRURSttablestlast_rowRt max_row_widthR5tactivet last_contentR:tis_last_row_header(RRRS((s//usr/lib/python2.7/site-packages/prettytable.pyRUVs        cCs%||_|dkr!t|_ndS(Ntth(RBR9RD(RRttagtattrs((s//usr/lib/python2.7/site-packages/prettytable.pythandle_starttagas  cCs|dkr.|jj}|jj|n|dkr|jj|j|jft|jt|j|_g|_t |_n|dkr|j |j}|j j|g|_nd|_d|_ dS(NREttdttrR7R](sthRI(RCR4R@RRRDRRARR:tgenerate_tableR?R5RB(RRRFtstripped_contentR7((s//usr/lib/python2.7/site-packages/prettytable.pyt handle_endtagfs        cCs|j|7_dS(N(RC(RRtdata((s//usr/lib/python2.7/site-packages/prettytable.pyt handle_dataxscCst|j}x|jD]}t|d|jkr}|jt|d}x+td|D]}|djdq_Wn|dtkr|j|d|d|_ q|j |dqW|S(sE Generates from a list of rows a PrettyTable object. iiR#( R RSRRRARRR9tmake_fields_uniqueR0Rk(RRRR7RqtappendsR((s//usr/lib/python2.7/site-packages/prettytable.pyRK{scCsoxhtdt|D]Q}xHt|dt|D]-}||||kr6||cd7Ts     cKs t|}|j||jS(s Generates a list of PrettyTables from a string of HTML code. Each in the HTML becomes one PrettyTable object. (R>tfeedR?(t html_codeRStparser((s//usr/lib/python2.7/site-packages/prettytable.pyt from_htmls  cKs;t||}yWntk r2tdnX|dS(sf Generates a PrettyTables from a string of HTML code which contains only a single
sDMore than one
in provided HTML code! Use from_html instead.i(RWRRm(RURSR?((s//usr/lib/python2.7/site-packages/prettytable.pyt from_html_ones  cCstddddg}d|_t|_d|jdR@RRRRRRtcompileR+R tobjectR R'RR5R8R=R>RWRXRcR(((s//usr/lib/python2.7/site-packages/prettytable.pyt s`            !   B