mς eγΈEc@s¨dZdZdkZdkZdklZlZlZl Z dk l Z dk l Z y dkZWnej o dZnXy dkZWnej o dZnXyeWn!ej od Zd ZnXd„Zd%e_hd e itZdZdZdZeZeZdZe i Z d„Z RS(s/CSV dialect for `csv_table` directive function.t,t"s cCs―|idƒot|dƒ|_n|idƒo t|_n|idƒot|dƒ|_n|idƒo t|_t|dƒ|_ nt i i |ƒdS(Ntdelimt keepspacetquotetescape( Rthas_keytstrtselft delimitertFalsetskipinitialspacet quotechart doublequotet escapechartcsvtDialectt__init__(R-R((RR6Xs  ( t__name__t __module__t__doc__R.R1tTrueR2R0tlineterminatorR4t QUOTE_MINIMALtquotingR6(((RR$Ms  t HeaderDialectcBs;tZdZdZdZdZeZeZ dZ e i Z RS(s0CSV dialect to use for the "header" option data.R%R&s\s (R7R8R9R.R1R3R/R2R:R0R;R4R<R=(((RR>es c Csfy‹|iii oV|idƒp|idƒo6|iid|t i ||ƒd|ƒ} | gSnt||||ƒt|||ƒ\}}t|||||||ƒ\} }t|||ƒ\}}t| t|ƒ||ƒ\}}t||ƒ}|iddƒ}|iddƒ} t"||| ||||ƒ|i#|| ƒ||} t%||||||ƒ}t'||| fƒWnrt(j o}|i*dgSnQt+i,j oA}|ii-d||ft i ||ƒd|ƒ}|gSnX||| f} |i/| || ƒ}|d c|id gƒ7<|o|i2d|ƒn|g|S( Ntfileturls9File and URL access deactivated; ignoring "%s" directive.Rs header-rowsis stub-columnss)Error with CSV data in "%s" directive: %sRR(3Rtdocumenttsettingstfile_insertion_enabledRR+RRRRR R R R tcheck_requirementsR RRRt get_csv_dataRtcsv_datatsourcetprocess_header_optiont table_headtmax_header_colstparse_csv_data_into_rowsR$trowstmax_colstmaxRt header_rowst stub_columnstcheck_table_dimensionstextendt table_bodytget_column_widthst col_widthst"extend_short_rows_with_empty_cellstSystemMessagePropagationtdetailtargsR4tErrorRRt build_tableRRR(RRRRR RR RRRSRPRRRFRLRRXRGRRMRIRJRORURR((Rt csv_tablers>1 $!   s header-rowss stub-columnstheadertwidthsR?R@tencodingR'R(R)R*cCsYtpN|iid|tiiƒdfti ||ƒd|ƒ}t |ƒ‚ndS(NsuThe "%s" directive is not compatible with this version of Python (%s). Requires the "csv" module, new in Python 2.3.iR( R4RRRRtsystversiontsplitR R R R RW(RR R RR((RRD―s#c Csb|id|iiiƒ}|ot|idƒp|idƒo;|i i d|t i||ƒd|ƒ}t|ƒ‚n|idƒ} |} nΓ|idƒoX|idƒo;|i i d|t i||ƒd|ƒ}t|ƒ‚ntiitii|iiƒƒ} tiitii| |dƒƒ} tid| ƒ} yY|iiii | ƒt!i"d| d|d |iii#d dƒ}|i%ƒi&ƒ} WqXt'j oF}|i i(d ||ft i||ƒd|ƒ} t| ƒ‚qXXn[|idƒot)p;|i i(d |t i||ƒd|ƒ} t| ƒ‚n|d} yt)i*| ƒi%ƒ} Wnht)i,t't-t.fj oM}|i i(d ||d|ft i||ƒd|ƒ} t| ƒ‚nXt!i/d| d| d|d |iii#ƒ}|i%ƒi&ƒ} n8|i i0d|t i||ƒd|ƒ}t|ƒ‚| | fS(sk CSV data can come from the directive content, from an external file, or from a URL reference. R_R?R@sF"%s" directive may not both specify an external file and have content.RisXThe "file" and "url" options may not be simultaneously specified for the "%s" directive.t source_patht error_handlerthandle_io_errorss&Problems with "%s" directive path: %s.sProblems with the "%s" directive and its "url" option: unable to access the required functionality (from the "urllib2" module).s*Problems with "%s" directive URL "%s": %s.RGs3The "%s" directive requires content; none supplied.N(1RRRRARBtinput_encodingR_RR+RRRRR R R R RWRGRFtostpathtdirnametabspathtcurrent_sourcet source_dirtnormpathtjointutilst relative_pathR#trecord_dependenciestaddtiot FileInputtinput_encoding_error_handlertcsv_filetreadt splitlinestIOErrortsevereturllib2turlopentcsv_texttURLErrortOSErrort ValueErrort StringInputR(RRRR R RRR_RvR}RlRFRGRzR((RREΈs\  $%   cCsu|i|dƒ}g}d}|idƒo<t|di dƒt ƒ||ƒ\}}|i |ƒn||fS(NiiR]s ( Rt get_sourceR RGRIRJRR+RKRbR>RLRR(RRR RJRGRLRI((RRHόs+c Csάtig}|D]} || idƒq~d|ƒ}g}d} xŠ|D]‚}g} xQ|D]I}t |dƒ} dddti| iƒd|ƒf} | i| ƒq_W|i| ƒt| t|ƒƒ} qLW|| fS(Nsutf-8tdialectiRG(R4treadert_[1]RFRtencodeRƒt csv_readerRLRMtrowtrow_datatcelltunicodet cell_textt statemachinet StringListRxRGt cell_datatappendRNR(RFRƒRGRRˆRLR‡RŠR…R‰RRŒRMR((RRKs- ' c Cs₯t|ƒ|joJ|iid|t|ƒ|fti||ƒd|ƒ}t |ƒ‚nt|ƒ|jo djnoG|iidt|ƒ|fti||ƒd|ƒ}t |ƒ‚nxΦ|D]Ξ}t|ƒ|joJ|iid|t|ƒ|fti||ƒd|ƒ}t |ƒ‚nt|ƒ|jo djnoG|iidt|ƒ|fti||ƒd|ƒ}t |ƒ‚qΟqΟWdS(NsP%s header row(s) specified but only %s row(s) of data supplied ("%s" directive).RiseInsufficient data supplied (%s row(s)); no data remaining for table body, required by "%s" directive.sU%s stub column(s) specified but only %s columns(s) of data supplied ("%s" directive).siInsufficient data supplied (%s columns(s)); no data remaining for table body, required by "%s" directive.(RRLRORRRRR R R R RWRˆRP( RLRORPRR R RRRˆ((RRQs$$$cCsΕ|idƒob|d}t|ƒ|joA|iid||ft i ||ƒd|ƒ}t |ƒ‚qΑnP|od|g|}n4|iidt i ||ƒd|ƒ}t |ƒ‚|S(NR^s="%s" widths do not match the number of columns in table (%s).Rids#No table data detected in CSV file.(RR+RURRMRRRRR R R R RW(RMRRR R RRUR((RRT5s   cCsgx`|D]X}xO|D]G}t|ƒ|jo.|idddgfg|t|ƒƒqqWqWdS(Ni(tpartstpartRˆRtcolumnsRR(R“R‘R’Rˆ((RRVHs c Cs |p6|iid|ti||ƒd|ƒ}|gSnt |||ƒ\} }tiƒ}|i|||ƒy―t|||||||ƒ\}}g}|dD]/} |g}| dD]}||iqΒ~qͺ~} |iddƒ}|iddƒ} t| || ||||ƒWn#t j o} | i"dgSnXt#| ||| ƒ}|dc|idgƒ7<| o|i%d| ƒn|g|S( sΌ Implement tables whose data is encoded as a uniform two-level bullet list. For further ideas, see http://docutils.sf.net/docs/dev/rst/alternatives.html#list-driven-tables s.The "%s" directive is empty; content required.Ris header-rowss stub-columnsRRN(&RRRRRR R R R R RRRRRRRRtcheck_list_contentRtnum_colsRUR…trow_listt_[2]titemtchildrent table_dataRRORPRQRWRXRYtbuild_table_from_listRR(RRRRR RR RRRPRšRRXR–R—RRRORURR…R˜R•R((Rt list_tableNs.  $G  c Cst|ƒdjpt|dtiƒ o;|iid|ti ||ƒd|ƒ} t | ƒ‚n|d} xtt| ƒƒD]}| |}t|ƒdjpt|dtiƒ oE|iid||dfti ||ƒd|ƒ} t | ƒ‚qƒ|opt|dƒ| joU|iid||dt|dƒ| fti ||ƒd|ƒ} t | ƒ‚qŠqƒt|dƒ} qƒWt| |||||ƒ} t| ƒ| joJ|iid|t| ƒ| fti ||ƒd|ƒ} t | ƒ‚n| | fS(NiisUError parsing content block for the "%s" directive: exactly one bullet list expected.Rs‹Error parsing content block for the "%s" directive: two-level bullet list expected, but row %s does not contain a second-level bullet list.s₯Error parsing content block for the "%s" directive: uniform two-level bullet list expected, but row %s does not contain the same number of items as row 1 (%s vs %s).spError parsing "widths" option of the "%s" directive: number of columns does not match the table data (%s vs %s).(RRRR t bullet_listRRRRR R R RWt list_nodetranget item_indexR˜R•RTRRU( RRRRR R RR R˜R•RžRRU((RR”ws0+  +*cCs;tiƒ} tidt|ƒƒ}| |7} xL|D]D}tid|ƒ}|od|id<|d8}n||7}q5Wg} xX|D]P}ti ƒ}x.|D]&} tiƒ} | | 7} || 7}q£W| i|ƒqŠW|o+tiƒ} | i| | ƒ|| 7}ntiƒ}|i| |ƒ||7}| S(Ntcolstcolwidthitstub(R RttgroupRRUt col_widthtcolspecRPt attributesRLRšRˆtrow_nodeRŠtentryRROttheadRRttbody(RšRURORPR₯R€R¦R¨R«RŠRLR©RRͺRˆ((RR›£s8         (iii(iii(iii(2R9t __docformat__R`tos.pathRgtdocutilsRsR RRotdocutils.utilsRWtdocutils.parsers.rstt directivesR4t ImportErrorR#R{R:t NameErrorR/RRt class_optionRRR R5R$R>R\tnonnegative_intt unchangedtpositive_int_listRhturiR_t$single_char_or_whitespace_or_unicodetflagtsingle_char_or_unicodeRDRERHRKRQRTRVRœR”R›(RTRsRoR¬R›R$RERR>RQR\R±RDR R4R:R{RœR`RVR RWR/RRHR”RKRg((Rt? sX              * ™  D     " 9  ,