Module rst_table: format a table in restructured text (reST) format

Nicely format a table, output in restructured text (reST) format

class APSpy.rst_table.Table[source]

Construct a table in reST (using no row or column spans)

Each cell may have multiple lines, separated by a newline (n) character.

For example, this code:

1
2
3
4
5
6
7
from rst_table import Table
t = Table()
t.labels = ('Name', 'Type', 'Units', 'Description', )
t.rows.append( ['uno', 'dos', 'tres', 'quatro', ] )
t.rows.append( ['class', 'NX_FLOAT', '..', '..', ] )
t.rows.append( ['1', '2', '3', '4', ] )
print t.reST()

generates this output:

1
2
3
4
5
6
7
===== ======== ===== ===========
Name  Type     Units Description
===== ======== ===== ===========
uno   dos      tres  quatro     
class NX_FLOAT ..    ..         
1     2        3     4          
===== ======== ===== ===========

which looks like this when formatted:

Name Type Units Description
uno dos tres quatro
class NX_FLOAT
1 2 3 4

class methods

complex_table(indentation='', add_tabularcolumns=True)[source]

return the table in complex rest format

Name and Attributes Type Units Description (and Occurrences)
one, two buckle my

shoe.

three, four

...
uno dos tres quatro
class NX_FLOAT
1 2 3 4
find_widths()[source]

measure the maximum width of each column, considering possible line breaks in each cell

list_table(indentation='', add_tabularcolumns=True, title='Table')[source]

return the table in list-table rest format (experimental)

from: http://docutils.sourceforge.net/docs/ref/rst/directives.html

Table
Name Type Units Description
and     (and Occurrences)
Attributes      
one, two buckle my

shoe.

three, four

...
uno dos tres quatro
class NX_FLOAT
1 2 3 4
reST(indentation='', format='simple', **kws)[source]

return the table in reST format

format may be one of these: simple (default), complex, or list

simple_table(indentation='', add_tabularcolumns=True)[source]

return the table in simple rest format

Name Type Units Description
and     (and Occurrences)
Attributes      
one, buckle my shoe. ...
two      
three, four
uno dos tres quatro
class NX_FLOAT
1 2 3 4

Previous topic

Module motor: (internal) motor support classes

Next topic

About APSpy

This Page