MCPcopy Index your code
hub / github.com/astanin/python-tabulate / _align_header

Function _align_header

tabulate/__init__.py:1388–1408  ·  view source on GitHub ↗

Pad string header to width chars given known visible_width of the header.

(
    header, alignment, width, visible_width, is_multiline=False, width_fn=None
)

Source from the content-addressed store, hash-verified

1386
1387
1388def _align_header(
1389 header, alignment, width, visible_width, is_multiline=False, width_fn=None
1390):
1391 "Pad string header to width chars given known visible_width of the header."
1392 if is_multiline:
1393 header_lines = re.split(_multiline_codes, header)
1394 padded_lines = [
1395 _align_header(h, alignment, width, width_fn(h)) for h in header_lines
1396 ]
1397 return "\n".join(padded_lines)
1398 # else: not multiline
1399 ninvisible = len(header) - visible_width
1400 width += ninvisible
1401 if alignment == "left":
1402 return _padright(width, header)
1403 elif alignment == "center":
1404 return _padboth(width, header)
1405 elif not alignment:
1406 return f"{header}"
1407 else:
1408 return _padleft(width, header)
1409
1410
1411def _remove_separating_lines(rows):

Callers 1

tabulateFunction · 0.85

Calls 3

_padrightFunction · 0.85
_padbothFunction · 0.85
_padleftFunction · 0.85

Tested by

no test coverage detected