| 116 | |
| 117 | |
| 118 | def convert_to_vertical_table(sections): |
| 119 | # Any section that only has a single row is |
| 120 | # inverted, so: |
| 121 | # header1 | header2 | header3 |
| 122 | # val1 | val2 | val2 |
| 123 | # |
| 124 | # becomes: |
| 125 | # |
| 126 | # header1 | val1 |
| 127 | # header2 | val2 |
| 128 | # header3 | val3 |
| 129 | for i, section in enumerate(sections): |
| 130 | if len(section.rows) == 1 and section.headers: |
| 131 | headers = section.headers |
| 132 | new_section = Section() |
| 133 | new_section.title = section.title |
| 134 | new_section.indent_level = section.indent_level |
| 135 | for header, element in zip(headers, section.rows[0]): |
| 136 | new_section.add_row([header, element]) |
| 137 | sections[i] = new_section |
| 138 | |
| 139 | |
| 140 | class IndentedStream: |