(self, section, max_width, stream)
| 347 | stream.write(''.join(parts)) |
| 348 | |
| 349 | def _render_rows(self, section, max_width, stream): |
| 350 | if not section.rows: |
| 351 | return |
| 352 | widths = section.calculate_column_widths( |
| 353 | padding=4, max_width=max_width |
| 354 | ) |
| 355 | if not widths: |
| 356 | return |
| 357 | self._write_line_break(stream, widths) |
| 358 | for row in section.rows: |
| 359 | # TODO: Built the string in a list then join instead of using +=, |
| 360 | # it's more efficient. |
| 361 | current = '' |
| 362 | length_so_far = 0 |
| 363 | first = True |
| 364 | for width, element in zip(widths, row): |
| 365 | if first: |
| 366 | left_edge = '|' |
| 367 | first = False |
| 368 | else: |
| 369 | left_edge = '' |
| 370 | stylized = self._styler.style_row_element(element) |
| 371 | current += align_left( |
| 372 | text=stylized, |
| 373 | length=width, |
| 374 | left_edge=left_edge, |
| 375 | right_edge=self._column_separator, |
| 376 | text_length=get_text_length(element), |
| 377 | ) |
| 378 | length_so_far += width |
| 379 | stream.write(current + '\n') |
| 380 | self._write_line_break(stream, widths) |
| 381 | |
| 382 | |
| 383 | class Section: |
no test coverage detected