Function
_pad
(cell: Text, width: int, align: str | None)
Source from the content-addressed store, hash-verified
| 341 | |
| 342 | |
| 343 | def _pad(cell: Text, width: int, align: str | None) -> Text: |
| 344 | padding = max(0, width - cell.cell_len) |
| 345 | if not padding: |
| 346 | return cell |
| 347 | if align and "center" in align: |
| 348 | left = padding // 2 |
| 349 | right = padding - left |
| 350 | out = Text(" " * left) |
| 351 | out.append_text(cell) |
| 352 | out.append(" " * right) |
| 353 | return out |
| 354 | if align and "right" in align: |
| 355 | out = Text(" " * padding) |
| 356 | out.append_text(cell) |
| 357 | return out |
| 358 | out = Text() |
| 359 | out.append_text(cell) |
| 360 | out.append(" " * padding) |
| 361 | return out |
| 362 | |
| 363 | |
| 364 | def _rstrip_trailing_space(text: Text) -> Text: |
Tested by
no test coverage detected