I think this can be corrected on header by using this:
def format_headers(string):
s = max(width - _ansi_len(string), 0)
return (' ' * (s / 2)) + string + (' ' * (s - (s / 2))) if s else string
data = map(format_headers, headers)
Also the _ansi_len should be rewritten:
def _ansi_len(string):
"""Extra length due to any ANSI sequences in the string."""
return len(re.sub(r'\x1b\[([0-9,A-Z]{1,2}(;[0-9]{1,2})?(;[0-9]{3})?)?[m|K]?', '', string))
The column size is improperly computed with the following example:
It gives:
I think this can be corrected on
header
by using this:Also the
_ansi_len
should be rewritten: