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

Method _len

tabulate/__init__.py:2749–2756  ·  view source on GitHub ↗

Custom len that gets console column width for wide and non-wide characters as well as ignores color codes

(item)

Source from the content-addressed store, hash-verified

2747
2748 @staticmethod
2749 def _len(item):
2750 """Custom len that gets console column width for wide
2751 and non-wide characters as well as ignores color codes"""
2752 stripped = _strip_ansi(item)
2753 if wcwidth:
2754 return wcwidth.wcswidth(stripped)
2755 else:
2756 return len(stripped)
2757
2758 def _update_lines(self, lines, new_line):
2759 """Adds a new line to the list of lines the text is being wrapped into

Callers 3

_handle_long_wordMethod · 0.95
_wrap_chunksMethod · 0.95

Calls 1

_strip_ansiFunction · 0.85

Tested by 1