3 S @s~dZdZddlZddlZddlZddlmZmZm Z m Z ddl m Z ddl mZddl mZddlmZGd d d ejZdS) ajImplements the CSVFTable docutils directive. License :: This work was created by participants in the DataONE project, and is jointly copyrighted by participating institutions in DataONE. For more information on DataONE, see our web site at http://dataone.org. Copyright 2010 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. reStructuredTextN)ionodes statemachineutils)SystemMessagePropagation) Directive) directives)tablescsbeZdZdZejejejejejej ej ej ej ej ejejejd ZddZfddZZS) CSVFTableaExtends docutils_ csvtable_ by adding a columns parameter to specify which columns from the data source are to be rendered. .. _docutils: http://docutils.sourceforge.net .. _csvtable: http://docutils.sourceforge.net/docs/ref/rst/directives.html#id1 ) z header-rowsz stub-columnsheaderwidthsfileurlencodingclassdelim keepspacequoteescapecolumnscCsd}d|jkr|jd}|S)Nr)options)selfrro/var/lib/jenkins/jobs/DataONE-Operations-Manual/workspace/operations/tools/docutils/rst_directives/csvftable.py get_columnsAs  zCSVFTable.get_columnsc sj}|dkr$ttj|||Stjfdd|D|d}g}t|}xx|D]p}dgt|} d} xN|D]F} | |krj| } dddtj | j |df} | | |j | <| d7} qnW|j | qRW||fS)Ncsg|]}j|dqS) )encode_for_csv).0line)rrr Osz6CSVFTable.parse_csv_data_into_rows..)dialectr)source) rsuperr parse_csv_data_into_rowscsvreaderlendecode_from_csvr StringList splitlinesindexappend)rcsv_datar!r$r csv_readerrowsmax_colsrowrow_dataicell cell_text cell_data) __class__)rrr&Hs,      z"CSVFTable.parse_csv_data_into_rows)__name__ __module__ __qualname____doc__r nonnegative_int unchangedpositive_int_listpathurir class_option$single_char_or_whitespace_or_unicodeflagsingle_char_or_unicode option_specrr& __classcell__rr)r9rr &s  r )r= __docformat__sysZos.pathosr'docutilsrrrrdocutils.utilsrdocutils.parsers.rstrr Zdocutils.parsers.rst.directivesr CSVTabler rrrrs