Commit 3da2c9ef authored by arthur-zzz's avatar arthur-zzz
Browse files

Fix format_table

parent af2c47ff
Pipeline #34265 passed with stages
in 29 minutes and 21 seconds
# ---------------------------------------------------------------------
# Various text-processing utilities
# ---------------------------------------------------------------------
# Copyright (C) 2007-2020 The NOC Project
# Copyright (C) 2007-2021 The NOC Project
# See LICENSE for details
# ---------------------------------------------------------------------
......@@ -12,6 +12,9 @@ from itertools import zip_longest
# Third-party modules
from typing import List, Union, Iterable
# NOC modules
from noc.core.comp import smart_text
rx_header_start = re.compile(r"^\s*[-=]+[\s\+]+[-=]+")
rx_col = re.compile(r"^([\s\+]*)([\-]+|[=]+)")
......@@ -530,7 +533,7 @@ def format_table(widths, data, sep=" ", hsep=" "):
# Calculate column widths
widths = list(widths)
for row in data:
widths = [max(x, len(y)) for x, y in zip(widths, row)]
widths = [max(x, len(smart_text(y, errors="replace"))) for x, y in zip(widths, row)]
# Build print mask
mask = sep.join("%%-%ds" % w for w in widths)
out = [
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment