ó V!¶\c@s÷dZdZddlZddlZddlZddlmZmZm Z m Z ddl m Z ddl mZddlmZddlmZd „Zd efd „ƒYZd efd „ƒYZdefd„ƒYZdefd„ƒYZdS(s Directives for table elements. treStructuredTextiÿÿÿÿN(tiotnodest statemachinetutils(t SafeString(tSystemMessagePropagation(t Directive(t directivescCstj|dƒS(Ntlefttcentertright(sleftscentersright(Rtchoice(targument((sJ/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/directives/tables.pytalignstTablecBs“eZdZdZeZiejd6ejd6e d6ej dej ƒd6Z eZ d„Zd „Zd „Zed „ƒZd „Zd „ZRS(s# Generic table base class. itclasstnameRtautotgridtwidthscCsƒ|jrm|jd}|jj||jƒ\}}tj|d|Œ}|jj|jƒ\|_|_ n d}g}||fS(Nit( t argumentststatet inline_texttlinenoRttitlet state_machinetget_source_and_linetsourcetlinetNone(tselft title_textt text_nodestmessagesR((sJ/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/directives/tables.pyt make_title*s   $cCs|jj|jdƒ}g}d}d|jkru|j|jdjdƒ|jƒ|ƒ\}}|j|ƒn||fS(Niitheaders (Rt get_sourceRtoptionstparse_csv_data_into_rowstsplitt HeaderDialecttextend(R Rt table_headtmax_header_colstrows((sJ/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/directives/tables.pytprocess_header_option7scCs×t|ƒ|krj|jjjd|t|ƒ|jftj|j|jƒd|jƒ}t |ƒ‚nt|ƒ|ko‡dknrá|jjjdt|ƒ|jftj|j|jƒd|jƒ}t |ƒ‚nxï|D]ç}t|ƒ|krX|jjjd|t|ƒ|jftj|j|jƒd|jƒ}t |ƒ‚nt|ƒ|koudknrè|jjjdt|ƒ|jftj|j|jƒd|jƒ}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.( tlenRtreporterterrorRRt literal_blockt block_textRR(R R.t header_rowst stub_columnsR2trow((sJ/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/directives/tables.pytcheck_table_dimensionsBs2 "   " cCs|jjddƒS(NRR(R'tget(R ((sJ/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/directives/tables.pyRascCsât|jƒtkr…t|jƒ|kry|jjjd|j|ftj |j |j ƒd|j ƒ}t |ƒ‚n|j}nY|rŸd|g|}n?|jjjdtj |j |j ƒd|j ƒ}t |ƒ‚|S(Ns="%s" widths do not match the number of columns in table (%s).Rids#No table data detected in CSV file.( ttypeRtlistR0RR1R2RRR3R4RR(R tmax_colsR2t col_widths((sJ/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/directives/tables.pytget_column_widthses     cCsex^|D]V}xM|D]E}t|ƒ|kr|jdddgfg|t|ƒƒqqWqWdS(Ni(R0R+(R tcolumnstpartstpartR7((sJ/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/directives/tables.pyt"extend_short_rows_with_empty_cellsws  (RR(t__name__t __module__t__doc__toptional_argumentstTruetfinal_argument_whitespaceRt class_optiont unchangedRtvalue_ortpositive_int_listt option_spect has_contentR$R/R8tpropertyRR>RB(((sJ/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/directives/tables.pyRs     tRSTTablecBseZd„ZRS(c Cs.|jsJ|jjjd|jtj|j|jƒd|jƒ}|gS|j ƒ\}}tj ƒ}|j j |j|j |ƒt|ƒdks­t|dtjƒ rî|jjjd|jtj|j|jƒd|jƒ}|gS|d}|dc|jjdgƒ7RBRtargsRytErrortstrtsyst version_infoR2t build_tableRXRR^R_(R RURR#tcsv_dataRR,R-R.R<R5R6t table_bodyR=tdetailtmessageR2RZRa((sJ/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/directives/tables.pyRfæsZ   !      c Cs˜|jjd|jjjjƒ}|jjjj}|jrÁd|jksZd|jkr£|jj j d|j t j |j|jƒd|jƒ}t|ƒ‚n|jjdƒ}|j}nÍd|jkrAd|jkr(|jj j d|j t j |j|jƒd|jƒ}t|ƒ‚ntjjtjj|jjjƒƒ}tjjtjj||jdƒƒ}tjd |ƒ}yM|jjjjj|ƒtjd|d|d |ƒ}|j ƒj!ƒ}WqŽt"k r=}|jj j#d |j t$|ƒft j |j|jƒd|jƒ}t|ƒ‚qŽXnMd|jkrHd d l%} |jd}y| j&|ƒj ƒ} Wn~| j't"t(t)fk r}|jj j#d |j |jdt$|ƒft j |j|jƒd|jƒ}t|ƒ‚nXtj*d| d|d|d |jjjjƒ}|j ƒj!ƒ}nF|jj j+d|j t j |j|jƒd|jƒ}t|ƒ‚||fS(sr Get CSV data from the directive content, from an external file, or from a URL reference. RjRhRisF"%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_handleru&Problems with "%s" directive path: %s.iÿÿÿÿNs*Problems with "%s" directive URL "%s": %s.Rs3The "%s" directive requires content; none supplied.(,R'R9RRR‚tinput_encodingtinput_encoding_error_handlerRTRR1R2RRR3R4RRRtostpathtdirnametabspathtcurrent_sourcetnormpathtjoinRt relative_pathRtrecord_dependenciestaddRt FileInputtreadt splitlinestIOErrortsevereRturllib2turlopentURLErrortOSErrort ValueErrort StringInputRU( R RjR‘R2RRŒt source_dirtcsv_fileR¢R£tcsv_text((sJ/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/directives/tables.pyR„sx                   icCs |jdƒS(Nsutf-8(tdecode(ts((sJ/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/directives/tables.pytdecode_from_csvascCs |jdƒS(Nsutf-8(tencode(R­((sJ/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/directives/tables.pyRrcscCs|S(N((R­((sJ/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/directives/tables.pyR®fscCs|S(N((R­((sJ/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/directives/tables.pyRrhsc CsØtjg|D]}|j|dƒ^q d|ƒ}g}d}xŠ|D]‚}g} xQ|D]I} |j| ƒ} dddtj| jƒd|ƒf} | j| ƒq[W|j| ƒt|t |ƒƒ}qHW||fS(Ns tdialectiR( RytreaderRrR®Rt StringListR tappendR…R0( R RŒR°RRt csv_readerR.R<R7trow_datatcellt cell_textt cell_data((sJ/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/directives/tables.pyR(ms #    (sauto(i(RCRDRtnonnegative_intRJRKRLR•turiRjRIRt$single_char_or_whitespace_or_unicodetflagtsingle_char_or_unicodeRMRyRzRoR*R€RfR„R‰RŠR®Rrt staticmethodR((((sJ/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/directives/tables.pyRg§s8                / J      t ListTablecBsteZdZiejd6ejd6ejd ejƒd6ejd6ejd6e d6Z d„Z d „Z d „Z RS( 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 header-rowss stub-columnsRRRRRcCsÂ|jsJ|jjjd|jtj|j|jƒd|jƒ}|gS|j ƒ\}}tj ƒ}|j j |j|j |ƒy|j|ƒ\}}g|dD]&}g|dD]}|j^q¸^q§} |jjddƒ} |jjddƒ} |j| | | ƒWntk r1} | jdgSX|j| || | ƒ} d|jkrr|jjdƒ| d(R R`R2t list_nodet item_indexRÄRÂR=((sJ/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/directives/tables.pyRÀ®s6)    )  ! cCs‘tjƒ}|jdkr1|dcdg7                 (sauto(RCRDRERR¹RKRLRIRJRRMRfRÀRÁ(((sJ/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/directives/tables.pyR¿s         '(REt __docformat__R‰tos.pathR”RytdocutilsRRRRtdocutils.utils.error_reportingRtdocutils.utilsRtdocutils.parsers.rstRRRRRPRgR¿(((sJ/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/directives/tables.pyts   " c)Ú