![]() |
Qucs-S S-parameter Viewer & RF Synthesis Tools
|


Public Member Functions | |
| setup (self, block) | |
| parse_table (self) | |
| mark_done (self, top, left, bottom, right) | |
| check_parse_complete (self) | |
| scan_cell (self, top, left) | |
| scan_right (self, top, left) | |
| scan_down (self, top, left, right) | |
| scan_left (self, top, left, bottom, right) | |
| scan_up (self, top, left, bottom, right) | |
| structure_from_cells (self) | |
Public Member Functions inherited from docutils.parsers.rst.tableparser.TableParser | |
| parse (self, block) | |
| find_head_body_sep (self) | |
Public Attributes | |
| block | |
| bottom | |
| right | |
| head_body_sep | |
| done | |
| cells | |
| rowseps | |
| colseps | |
| double_width_pad_char | |
Public Attributes inherited from docutils.parsers.rst.tableparser.TableParser | |
| block | |
| head_body_sep | |
Static Public Attributes | |
| head_body_separator_pat = re.compile(r'\+=[=+]+=\+ *$') | |
Static Public Attributes inherited from docutils.parsers.rst.tableparser.TableParser | |
| head_body_separator_pat = None | |
| str | double_width_pad_char = '\x00' |
Parse a grid table using `parse()`.
Here's an example of a grid table::
+------------------------+------------+----------+----------+
| Header row, column 1 | Header 2 | Header 3 | Header 4 |
+========================+============+==========+==========+
| body row 1, column 1 | column 2 | column 3 | column 4 |
+------------------------+------------+----------+----------+
| body row 2 | Cells may span columns. |
+------------------------+------------+---------------------+
| body row 3 | Cells may | - Table cells |
+------------------------+ span rows. | - contain |
| body row 4 | | - body elements. |
+------------------------+------------+---------------------+
Intersections use '+', row separators use '-' (except for one optional
head/body row separator, which uses '='), and column separators use '|'.
Passing the above table to the `parse()` method will result in the
following data structure::
([24, 12, 10, 10],
[[(0, 0, 1, ['Header row, column 1']),
(0, 0, 1, ['Header 2']),
(0, 0, 1, ['Header 3']),
(0, 0, 1, ['Header 4'])]],
[[(0, 0, 3, ['body row 1, column 1']),
(0, 0, 3, ['column 2']),
(0, 0, 3, ['column 3']),
(0, 0, 3, ['column 4'])],
[(0, 0, 5, ['body row 2']),
(0, 2, 5, ['Cells may span columns.']),
None,
None],
[(0, 0, 7, ['body row 3']),
(1, 0, 7, ['Cells may', 'span rows.', '']),
(1, 1, 7, ['- Table cells', '- contain', '- body elements.']),
None],
[(0, 0, 9, ['body row 4']), None, None, None]])
The first item is a list containing column widths (colspecs). The second
item is a list of head rows, and the third is a list of body rows. Each
row contains a list of cells. Each cell is either None (for a cell unused
because of another cell's span), or a tuple. A cell tuple contains four
items: the number of extra rows used by the cell in a vertical span
(morerows); the number of extra columns used by the cell in a horizontal
span (morecols); the line offset of the first line of the cell contents;
and the cell contents, a list of lines of text.
| docutils.parsers.rst.tableparser.GridTableParser.check_parse_complete | ( | self | ) |
Each text column should have been completely seen.
| docutils.parsers.rst.tableparser.GridTableParser.mark_done | ( | self, | |
| top, | |||
| left, | |||
| bottom, | |||
| right | |||
| ) |
For keeping track of how much of each text column has been seen.
| docutils.parsers.rst.tableparser.GridTableParser.parse_table | ( | self | ) |
Start with a queue of upper-left corners, containing the upper-left corner of the table itself. Trace out one rectangular cell, remember it, and add its upper-right and lower-left corners to the queue of potential upper-left corners of further cells. Process the queue in top-to-bottom order, keeping track of how much of each text column has been seen. We'll end up knowing all the row and column boundaries, cell positions and their dimensions.
| docutils.parsers.rst.tableparser.GridTableParser.scan_cell | ( | self, | |
| top, | |||
| left | |||
| ) |
Starting at the top-left corner, start tracing out a cell.
| docutils.parsers.rst.tableparser.GridTableParser.scan_down | ( | self, | |
| top, | |||
| left, | |||
| right | |||
| ) |
Look for the bottom-right corner of the cell, making note of all row boundaries.
| docutils.parsers.rst.tableparser.GridTableParser.scan_left | ( | self, | |
| top, | |||
| left, | |||
| bottom, | |||
| right | |||
| ) |
Noting column boundaries, look for the bottom-left corner of the cell. It must line up with the starting point.
| docutils.parsers.rst.tableparser.GridTableParser.scan_right | ( | self, | |
| top, | |||
| left | |||
| ) |
Look for the top-right corner of the cell, and make note of all column
boundaries ('+').
| docutils.parsers.rst.tableparser.GridTableParser.scan_up | ( | self, | |
| top, | |||
| left, | |||
| bottom, | |||
| right | |||
| ) |
Noting row boundaries, see if we can return to the starting point.
| docutils.parsers.rst.tableparser.GridTableParser.structure_from_cells | ( | self | ) |
From the data collected by `scan_cell()`, convert to the final data structure.