MCPcopy Create free account
hub / github.com/astanin/python-tabulate / _choose_width_fn

Function _choose_width_fn

tabulate/__init__.py:1154–1166  ·  view source on GitHub ↗

Return a function to calculate visible cell width.

(has_invisible, enable_widechars, is_multiline)

Source from the content-addressed store, hash-verified

1152
1153
1154def _choose_width_fn(has_invisible, enable_widechars, is_multiline):
1155 """Return a function to calculate visible cell width."""
1156 if has_invisible:
1157 line_width_fn = _visible_width
1158 elif enable_widechars: # optional wide-character support if available
1159 line_width_fn = wcwidth.wcswidth
1160 else:
1161 line_width_fn = len
1162 if is_multiline:
1163 width_fn = lambda s: _multiline_width(s, line_width_fn) # noqa: E731
1164 else:
1165 width_fn = line_width_fn
1166 return width_fn
1167
1168
1169def _align_column_choose_padfn(strings, alignment, has_invisible, preserve_whitespace):

Callers 1

tabulateFunction · 0.85

Calls 1

_multiline_widthFunction · 0.85

Tested by

no test coverage detected