Your IP : 216.73.216.213


Current Path : /opt/alt/python37/lib/python3.7/site-packages/logilab/common/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib/python3.7/site-packages/logilab/common/__pycache__/table.cpython-37.pyc

B

�d{T�z�@s�dZddlmZdZddlmZGdd�de�ZGdd�d�Zdd	l	Z	e	�
d
�ZGdd�d�ZGd
d�d�Z
Gdd�de
�ZGdd�d�ZGdd�de�Zd	S)zTable management module.�)�print_functionzrestructuredtext en)�rangec@sveZdZdZdXdd�Zdd�Zdd	�Zd
d�Zej	Z	dd
�Z
dd�Zdd�Zdd�Z
dYdd�Zdd�ZdZdd�Zd[dd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd\d+d,�Zd]d-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Zd9d:�Z d;d<�Z!d=d>�Z"d?d@�Z#e$e#�Z%dAdB�Z&dCdD�Z'dEdF�Z(d^dHdI�Z)dJdK�Z*d_dLdM�Z+dNdO�Z,dPdQ�Z-dRdS�Z.dTdU�Z/dVdW�Z0dS)`�Tablez�Table defines a data table with column and row names.
    inv:
        len(self.data) <= len(self.row_names)
        forall(self.data, lambda x: len(x) <= len(self.col_names))
    rNcCs8g|_g|_g|_||_|r&|�|�|r4|�|�dS)N)�	col_names�	row_names�data�
default_value�create_columns�create_rows)�selfrrr�r�E/opt/alt/python37/lib/python3.7/site-packages/logilab/common/table.py�__init__!s
zTable.__init__cCsdt|j�dS)Nzrow%s�)�lenr)rrrr
�_next_row_name+szTable._next_row_namecCs
t|j�S)N)�iterr)rrrr
�__iter__.szTable.__iter__cCs |dkrdSt|�t|�kSdS)NF)�list)r�otherrrr
�__eq__1szTable.__eq__cCs
||kS)Nr)rrrrr
�__ne__9szTable.__ne__cCs
t|j�S)N)rr)rrrr
�__len__<sz
Table.__len__cCs8|j�|�x&|D]}|j�|jgt|j��qWdS)z7Appends row_names to the list of existing rows
        N)r�extendr�appendrrr)rr�row_namerrr
r
@s
zTable.create_rowscCsx|D]}|�|�qWdS)z:Appends col_names to the list of existing columns
        N)�
create_column)rr�col_namerrr
r	Gs
zTable.create_columnscCs6|p
|��}|j�|�|j�|jgt|j��dS)z0Creates a rowname to the row_names list
        N)rrrrrrr)rrrrr
�
create_rowMszTable.create_rowcCs,|j�|�x|jD]}|�|j�qWdS)z0Creates a colname to the col_names list
        N)rrrr)rr�rowrrr
rUszTable.create_column�asccCsBy|j�|�}|�||�Wn tk
r<td|��YnXdS)zFSorts the table (in-place) according to data stored in col_id
        zCol (%s) not found in tableN)r�index�sort_by_column_index�
ValueError�KeyError)r�col_id�method�	col_indexrrr
�sort_by_column_id]s
zTable.sort_by_column_idcspt�fdd�t|j|j�D��}|��dkr4|��g|_g|_x*|D]"\}}}|j�|�|j�|�qFWdS)zvSorts the table 'in-place' according to data stored in col_index

        method should be in ('asc', 'desc')
        csg|]\}}|�||f�qSrr)�.0rr)r'rr
�
<listcomp>lsz.Table.sort_by_column_index.<locals>.<listcomp>�descN)�sorted�ziprr�lower�reverser)rr'r&Z	sort_list�valrrr)r'r
r"gszTable.sort_by_column_indexc	s�i}|f|}�fdd�|D�}xf�jD]\}|}x$|dd�D]}|�||i�}q>W|�||dt�j�jd��}|�t|��q(W|S)z]builds indexes of data
        :returns: nested dictionaries pointing to actual rows
        csg|]}�j�|��qSr)rr!)r)r%)rrr
r*�sz!Table.groupby.<locals>.<listcomp>N���)rr)r�
setdefaultrrr�
append_row�tuple)	r�colnameZothers�groupsZcolnamesZcol_indexesr�ptrr'r)rr
�groupbyzs
z
Table.groupbycCs,|�|�}y||Stk
r&gSXdS)N)r8r$)rr5�valueZgroupedrrr
�select�s

zTable.selectcCs@|j�|�}x.|jdd�D]}|||kr|j�|�qWdS)N)rr!r�remove)rr5r9r'rrrr
r;�szTable.removecCs||j||<dS)z<sets value of cell 'row_indew', 'col_index' to data
        N)r)r�	row_indexr'rrrr
�set_cell�szTable.set_cellcCsvy|j�|�}Wn tk
r0td|��YnBXy|j�|�}||j||<Wn tk
rptd|��YnXdS)z�sets value of cell mapped by row_id and col_id to data
        Raises a KeyError if row_id or col_id are not found in the table
        zRow (%s) not found in tablezColumn (%s) not found in tableN)rr!r#r$rr)r�row_idr%rr<r'rrr
�set_cell_by_ids�szTable.set_cell_by_idscCs||j|<dS)z�sets the 'row_index' row
        pre:
            type(row_data) == types.ListType
            len(row_data) == len(self.col_names)
        N)r)rr<�row_datarrr
�set_row�sz
Table.set_rowcCsBy|j�|�}|�||�Wn tk
r<td|��YnXdS)z�sets the 'row_id' column
        pre:
            type(row_data) == types.ListType
            len(row_data) == len(self.row_names)
        Raises a KeyError if row_id is not found
        zRow (%s) not found in tableN)rr!rAr#r$)rr>r@r<rrr
�
set_row_by_id�s
zTable.set_row_by_idcCs2|p
|��}|j�|�|j�|�t|j�dS)z�Appends a row to the table
        pre:
            type(row_data) == types.ListType
            len(row_data) == len(self.col_names)
        r)rrrrr)rr@rrrr
r3�szTable.append_rowcCs,|p
|��}|j�||�|j�||�dS)a,Appends row_data before 'index' in the table. To make 'insert'
        behave like 'list.insert', inserting in an out of range index will
        insert row_data to the end of the list
        pre:
            type(row_data) == types.ListType
            len(row_data) == len(self.col_names)
        N)rr�insertr)rr!r@rrrr
�
insert_row�szTable.insert_rowcCs|j�|�|j�|�S)ztDeletes the 'index' row in the table, and returns it.
        Raises an IndexError if index is out of range
        )r�popr)rr!rrr
�
delete_row�szTable.delete_rowcCs@y|j�|�}|�|�Wn tk
r:td|��YnXdS)zbDeletes the 'row_id' row in the table.
        Raises a KeyError if row_id was not found.
        zRow (%s) not found in tableN)rr!rFr#r$)rr>r<rrr
�delete_row_by_id�s
zTable.delete_row_by_idcCs(x"t|�D]\}}||j||<q
WdS)z�sets the 'col_index' column
        pre:
            type(col_data) == types.ListType
            len(col_data) == len(self.row_names)
        N)�	enumerater)rr'�col_datar<�	cell_datarrr
�
set_column�szTable.set_columncCsBy|j�|�}|�||�Wn tk
r<td|��YnXdS)z�sets the 'col_id' column
        pre:
            type(col_data) == types.ListType
            len(col_data) == len(self.col_names)
        Raises a KeyError if col_id is not found
        zColumn (%s) not found in tableN)rr!rKr#r$)rr%rIr'rrr
�set_column_by_id�s
zTable.set_column_by_idcCs6|j�|�x$t|�D]\}}|j|�|�qWdS)z�Appends the 'col_index' column
        pre:
            type(col_data) == types.ListType
            len(col_data) == len(self.row_names)
        N)rrrHr)rrIrr<rJrrr
�
append_columnszTable.append_columncCs:|j�||�x&t|�D]\}}|j|�||�qWdS)a,Appends col_data before 'index' in the table. To make 'insert'
        behave like 'list.insert', inserting in an out of range index will
        insert col_data to the end of the list
        pre:
            type(col_data) == types.ListType
            len(col_data) == len(self.row_names)
        N)rrCrHr)rr!rIrr<rJrrr
�
insert_columnszTable.insert_columncs |j����fdd�|jD�S)zwDeletes the 'index' column in the table, and returns it.
        Raises an IndexError if index is out of range
        csg|]}|����qSr)rE)r)r)r!rr
r*(sz'Table.delete_column.<locals>.<listcomp>)rrEr)rr!r)r!r
�
delete_column#szTable.delete_columncCs@y|j�|�}|�|�Wn tk
r:td|��YnXdS)zbDeletes the 'col_id' col in the table.
        Raises a KeyError if col_id was not found.
        zColumn (%s) not found in tableN)rr!rOr#r$)rr%r'rrr
�delete_column_by_id+s
zTable.delete_column_by_idcCst|j�t|j�fS)z;Returns a tuple which represents the table's shape
        )rrr)rrrr
�	get_shape8szTable.get_shapec	Cs�d\}}d\}}t|t�r8|d}t|�dkr<|d}n|}t|t�rxy|j�|�}Wn tk
rvtd|��YnXt|t�r�t	||d�}d}nt	d�}d}t|t�r�y|j
�|�}Wn tk
r�td|��YnXt|t�r�t	||d�}d}nt	d�}d}t�}|j|_|�
|j|�|�|j
|�x,t|j|�D]\}}|�|||��qFW|�r�|�rt|Sd	d
�|jD�Sn|�r�|jdS|jddSdS)zprovided for convenience)NFrrzRow (%s) not found in tableFNTzColumn (%s) not found in tablecSsg|]}|d�qS)rr)r)�itemrrr
r*ksz%Table.__getitem__.<locals>.<listcomp>)�
isinstancer4r�strrr!r#r$�int�slicerrrr
r	rHrrA)	r�indicesZrowsZ	multirows�colsZ	multicols�tab�idxrrrr
�__getitem__>sP






zTable.__getitem__cCsry|j�|�}Wn tk
r0td|��Yn4Xy|j�|�}Wn tk
rbtd|��YnX|j||S)z0Returns the element at [row_id][col_id]
        zRow (%s) not found in tablezColumn (%s) not found in table)rr!r#r$rr)rr>r%r<r'rrr
�get_cell_by_idsrszTable.get_cell_by_idscCs<y|j�|�}Wn tk
r0td|��YnX|j|S)z!Returns the 'row_id' row
        zRow (%s) not found in table)rr!r#r$r)rr>r<rrr
�
get_row_by_id�s
zTable.get_row_by_idFcCs>y|j�|�}Wn tk
r0td|��YnX|�||�S)z!Returns the 'col_id' col
        zColumn (%s) not found in table)rr!r#r$�
get_column)rr%�distinctr'rrr
�get_column_by_id�s
zTable.get_column_by_idcs�fdd�tt�j��D�S)z-Returns all the columns in the table
        csg|]}�dd�|f�qS)Nr)r)r!)rrr
r*�sz%Table.get_columns.<locals>.<listcomp>)rrr)rr)rr
�get_columns�szTable.get_columnscs(�fdd�|jD�}|r$tt|��}|S)zget a column by indexcsg|]}|��qSrr)r)r)r'rr
r*�sz$Table.get_column.<locals>.<listcomp>)rr�set)rr'r_�colr)r'r
r^�szTable.get_columncCsx|jD]}t|�qWdS)z-Applies the stylesheet to this table
        N)�instructions�eval)rZ
stylesheetZinstructionrrr
�apply_stylesheet�szTable.apply_stylesheetcCsHt�}|�|j�|�|j�x$t|���D]\}}|�||�q,W|S)zZKeeps the self object intact, and returns the transposed (rotated)
        table.
        )rr
rr	rrHrarA)rZ
transposedr'�columnrrr
�	transpose�szTable.transposec	Csfd}x"|jD]}t|�|krt|�}qW|d}g}d|g}x|jD]}|�|d�qFW|�dd�|�d�t|d�}x�t|j�D]�\}}	g}
|j|}|
�|d|t|��xHt|	�D]<\}}t|j|�d}
t|�}|
�|d|
t|��q�W|�dd�|
�d�t|d�|kr�t|d�}q�W|�dd|�|�d|�d�|�S)	z[returns a string representing the table in a pretty
        printed 'text' format.
        r�� z     �|r1�-�
)	rrrr�joinrHrrTrC)rZmax_row_namerZ	col_start�linesZcol_names_liner�max_line_lengthr<r�liner'�cellZcol_name_lengthrrrr
�pprint�s2

zTable.pprintcCs
t|j�S)N)�reprr)rrrr
�__repr__�szTable.__repr__cCs@g}x"|jD]}|�dd�|D��qWdd�|D�}d�|�S)NcSsg|]}t|��qSr)rT)r)rrrrr
r*�sz!Table.as_text.<locals>.<listcomp>cSsg|]}d�|��qS)�	)rn)r)rrrr
r*�srm)rrrn)rrrrorrr
�as_text�s
z
Table.as_text)rNN)N)r )r )N)N)F)F)1�__name__�
__module__�__qualname__�__doc__rrrr�object�__hash__rrr
r	rrr(r"r8r:r;r=r?rArBr3rDrFrGrKrLrMrNrOrPrQ�property�shaper[r\r]r`rar^rfrhrsrurwrrrr
rsX





	




4	
	
*rc@sxeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�ZdS)�
TableStylezDefines a table's style
    cCsj||_tdd�|jD��|_d|jd<tdd�|jD��|_d|jd<tdd�|jD��|_d|jd<dS)	NcSsg|]}|df�qS)z1*r)r)rrrr
r*�sz'TableStyle.__init__.<locals>.<listcomp>z1*�__row_column__cSsg|]}|df�qS)�rightr)r)rrrr
r*�sr�cSsg|]}|df�qS)�r)r)rrrr
r*�sr�)�_table�dictr�size�	alignment�units)r�tablerrr
r�s

zTableStyle.__init__cCs||j|<dS)z7sets the size of the specified col_id to value
        N)r�)rr9r%rrr
�set_size�szTableStyle.set_sizecCs,|dkrd}n|jj|d}||j|<dS)z�Allows to set the size according to the column index rather than
        using the column's id.
        BE CAREFUL : the '0' column is the '__row_column__' one !
        rr�rN)r�rr�)rr9r'r%rrr
�set_size_by_indexszTableStyle.set_size_by_indexcCs||j|<dS)z<sets the alignment of the specified col_id to value
        N)r�)rr9r%rrr
�
set_alignmentszTableStyle.set_alignmentcCs,|dkrd}n|jj|d}||j|<dS)z�Allows to set the alignment according to the column index rather than
        using the column's id.
        BE CAREFUL : the '0' column is the '__row_column__' one !
        rr�rN)r�rr�)rr9r'r%rrr
�set_alignment_by_indexsz!TableStyle.set_alignment_by_indexcCs||j|<dS)z7sets the unit of the specified col_id to value
        N)r�)rr9r%rrr
�set_unit"szTableStyle.set_unitcCs,|dkrd}n|jj|d}||j|<dS)a)Allows to set the unit according to the column index rather than
        using the column's id.
        BE CAREFUL :  the '0' column is the '__row_column__' one !
        (Note that in the 'unit' case, you shouldn't have to set a unit
        for the 1st column (the __row__column__ one))
        rr�rN)r�rr�)rr9r'r%rrr
�set_unit_by_index(szTableStyle.set_unit_by_indexcCs
|j|S)z1Returns the size of the specified col_id
        )r�)rr%rrr
�get_size7szTableStyle.get_sizecCs(|dkrd}n|jj|d}|j|S)z�Allows to get the size  according to the column index rather than
        using the column's id.
        BE CAREFUL : the '0' column is the '__row_column__' one !
        rr�r)r�rr�)rr'r%rrr
�get_size_by_index=szTableStyle.get_size_by_indexcCs
|j|S)z6Returns the alignment of the specified col_id
        )r�)rr%rrr
�
get_alignmentJszTableStyle.get_alignmentcCs(|dkrd}n|jj|d}|j|S)z�Allors to get the alignment according to the column index rather than
        using the column's id.
        BE CAREFUL : the '0' column is the '__row_column__' one !
        rr�r)r�rr�)rr'r%rrr
�get_alignment_by_indexPsz!TableStyle.get_alignment_by_indexcCs
|j|S)z1Returns the unit of the specified col_id
        )r�)rr%rrr
�get_unit]szTableStyle.get_unitcCs(|dkrd}n|jj|d}|j|S)z�Allors to get the unit according to the column index rather than
        using the column's id.
        BE CAREFUL : the '0' column is the '__row_column__' one !
        rr�r)r�rr�)rr'r%rrr
�get_unit_by_indexcszTableStyle.get_unit_by_indexN)rxryrzr{rr�r�r�r�r�r�r�r�r�r�r�r�rrrr
r��s



r�Nz([0-9]+)_([0-9]+)c@sBeZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)�TableStyleSheeta�A simple Table stylesheet
    Rules are expressions where cells are defined by the row_index
    and col_index separated by an underscore ('_').
    For example, suppose you want to say that the (2,5) cell must be
    the sum of its two preceding cells in the row, you would create
    the following rule :
        2_5 = 2_3 + 2_4
    You can also use all the math.* operations you want. For example:
        2_5 = sqrt(2_3**2 + 2_4**2)
    NcCs0|pg}g|_g|_x|D]}|�|�qWdS)N)�rulesrd�add_rule)rr��rulerrr
rs

zTableStyleSheet.__init__cCshyBdg}|�t�d|��|j�td�|�dd��|j�|�Wn tk
rbtd|�YnXdS)z,Adds a rule to the stylesheet rules
        zfrom math import *zself.data[\1][\2]rmztable.py�execz"Bad Stylesheet Rule : %s [skipped]N)	r�	CELL_PROG�subrd�compilernr��SyntaxError�print)rr�Zsource_coderrr
r��s
zTableStyleSheet.add_rulecs<�fdd�t||d�D�}d|d�|�}|�|�dS)a$Creates and adds a rule to sum over the row at row_index from
        start_col to end_col.
        dest_cell is a tuple of two elements (x,y) of the destination cell
        No check is done for indexes ranges.
        pre:
            start_col >= 0
            end_col > start_col
        csg|]}d�|f�qS)z%d_%dr)r)r!)r<rr
r*�sz3TableStyleSheet.add_rowsum_rule.<locals>.<listcomp>rz%d_%d=�+N)rrnr�)r�	dest_cellr<�	start_col�end_col�	cell_listr�r)r<r
�add_rowsum_rule�s	zTableStyleSheet.add_rowsum_rulecsT�fdd�t||d�D�}||d}d|dd�|�d|}|�|�dS)	aCreates and adds a rule to make the row average (from start_col
        to end_col)
        dest_cell is a tuple of two elements (x,y) of the destination cell
        No check is done for indexes ranges.
        pre:
            start_col >= 0
            end_col > start_col
        csg|]}d�|f�qS)z%d_%dr)r)r!)r<rr
r*�sz3TableStyleSheet.add_rowavg_rule.<locals>.<listcomp>rz%d_%d=�(r�z)/%fN)rrnr�)rr�r<r�r�r��numr�r)r<r
�add_rowavg_rule�s
	zTableStyleSheet.add_rowavg_rulecs<�fdd�t||d�D�}d|d�|�}|�|�dS)a$Creates and adds a rule to sum over the col at col_index from
        start_row to end_row.
        dest_cell is a tuple of two elements (x,y) of the destination cell
        No check is done for indexes ranges.
        pre:
            start_row >= 0
            end_row > start_row
        csg|]}d|�f�qS)z%d_%dr)r)r!)r'rr
r*�sz3TableStyleSheet.add_colsum_rule.<locals>.<listcomp>rz%d_%d=r�N)rrnr�)rr�r'�	start_row�end_rowr�r�r)r'r
�add_colsum_rule�s	zTableStyleSheet.add_colsum_rulecsT�fdd�t||d�D�}||d}d|dd�|�d|}|�|�dS)	aCreates and adds a rule to make the col average (from start_row
        to end_row)
        dest_cell is a tuple of two elements (x,y) of the destination cell
        No check is done for indexes ranges.
        pre:
            start_row >= 0
            end_row > start_row
        csg|]}d|�f�qS)z%d_%dr)r)r!)r'rr
r*�sz3TableStyleSheet.add_colavg_rule.<locals>.<listcomp>rz%d_%d=r�r�z)/%fN)rrnr�)rr�r'r�r�r�r�r�r)r'r
�add_colavg_rule�s
	zTableStyleSheet.add_colavg_rule)N)
rxryrzr{rr�r�r�r�r�rrrr
r�ss


r�c@sHeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dS)�TableCellRendererz#Defines a simple text renderer
    cKs
||_dS)a/keywords should be properties with an associated boolean as value.
        For example :
            renderer = TableCellRenderer(units = True, alignment = False)
        An unspecified property will have a 'False' value by default.
        Possible properties are :
            alignment, unit
        N)�
properties)rr�rrr
r�szTableCellRenderer.__init__cCs:|\}}|j||}|�|||d�}|�|||d�S)zIRenders the cell at 'cell_coord' in the table, using table_style
        r)r�_make_cell_content�_render_cell_content)rZ
cell_coordr��table_styler<r'�
cell_value�
final_contentrrr
�render_cell�szTableCellRenderer.render_cellcCs|}|�||d�S)z*Renders the cell for 'row_id' row
        r)r�)rrr�r�r�rrr
�render_row_cell�sz!TableCellRenderer.render_row_cellcCs"|}|j�|�}|�|||d�S)z*Renders the cell for 'col_id' row
        r)rr!r�)rrr�r�r�r'rrr
�render_col_cell�sz!TableCellRenderer.render_col_cellcCs|S)aMakes the appropriate rendering for this cell content.
        Rendering properties will be searched using the
        *table_style.get_xxx_by_index(col_index)' methods

        **This method should be overridden in the derived renderer classes.**
        r)r�contentr�r'rrr
r��sz&TableCellRenderer._render_cell_contentcCsh|}d|jkr|jd}nd}|r.|dkr.|Sy |jd}|rL|�|||�}Wntk
rbYnX|S)zVMakes the cell content (adds decoration data, like units for
        example)
        Z	skip_zerorr�)r��	_add_unitr$)r�cell_contentr�r'r��replacement_charZunits_onrrr
r�s

z$TableCellRenderer._make_cell_contentcCs|�|�}t|�d|S)z0Adds unit to the cell_content if needed
        rj)r�rT)rr�r�r'Zunitrrr
r�s
zTableCellRenderer._add_unitN)rxryrzr{rr�r�r�r�r�r�rrrr
r��s	
r�c@s eZdZdZdd�Zdd�ZdS)�DocbookRendererz6Defines how to render a cell for a docboook table
    cCs|�|�}d||fS)z<Computes the colspec element according to the style
        z'<colspec colname="c%d" colwidth="%s"/>
)r�)rr'r�r�rrr
�define_col_header*s
z!DocbookRenderer.define_col_headercCsFy(|jd}|�|�}|r&d||fSWntk
r@d|SXdS)z�Makes the appropriate rendering for this cell content.
        Rendering properties will be searched using the
        table_style.get_xxx_by_index(col_index)' methods.
        r�z<entry align='%s'>%s</entry>
z<entry>%s</entry>
N)r�r�r$)rr�r�r'Zalign_onr�rrr
r�2s

z$DocbookRenderer._render_cell_contentN)rxryrzr{r�r�rrrr
r�&sr�c@s:eZdZdZdd�Zdd�Zdd�Zdd	�Zddd�Zd
S)�TableWriterzA class to write tables
    cKs*||_|pt|�|_||_||_d|_dS)N)�_streamr��styler�r��renderer)r�streamr�r�r�rrr
rFs
zTableWriter.__init__cCs
||_dS)z*sets the table's associated style
        N)r�)rr�rrr
�	set_styleNszTableWriter.set_stylecCs
||_dS)z$sets the way to render cell
        N)r�)rr�rrr
�set_rendererTszTableWriter.set_renderercKs|j�|�dS)z9Updates writer's properties (for cell rendering)
        N)r��update)rr�rrr
�update_propertiesZszTableWriter.update_propertiesr�cCstd��dS)zWrites the table
        z!write_table must be implemented !N)�NotImplementedError)r�titlerrr
�write_table`szTableWriter.write_tableN)r�)	rxryrzr{rr�r�r�r�rrrr
r�Bsr�c@s*eZdZdZdd�Zdd�Zd
dd�Zd	S)�DocbookTableWriterzIDefines an implementation of TableWriter to write a table in Docbook
    cCs�x4tt|jj�d�D]}|j�|j�||j��qW|j�d�|j�d�x,|jjD] }|j�|j�	||j|j��qXW|j�d�dS)zWrites col headers
        rz<thead>
<row>
z<entry></entry>
z</row>
</thead>
N)
rrr�rr��writer�r�r�r�)rr'rrrr
�_write_headersksz!DocbookTableWriter._write_headersc	Cs�|j�d�x�t|jj�D]~\}}|j�d�|jj|}|j�|j�||j|j��x4t|�D](\}}|j�|j�	||f|j|j��q`W|j�d�qW|j�d�dS)zWrites the table body
        z<tbody>
z<row>
z</row>
z	</tbody>
N)
r�r�rHr�rrr�r�r�r�)rr<rrr'rrrrr
�_write_body~s
zDocbookTableWriter._write_bodyr�cCsL|j�d|�|j�dt|jj�d�|��|��|j�d�dS)zWrites the table
        z<table>
<title>%s></title>
z6<tgroup cols="%d" align="left" colsep="1" rowsep="1">
rz</tgroup>
</table>
N)r�r�rr�rr�r�)rr�rrr
r��szDocbookTableWriter.write_tableN)r�)rxryrzr{r�r�r�rrrr
r�gsr�)r{�
__future__r�
__docformat__Z	six.movesrr|rr��rer�r�r�r�r�r�r�rrrr
�<module>s Q	
`S%