Commit 126803b3 authored by Vincent Stehlé's avatar Vincent Stehlé
Browse files

parser.py: tune printing



Make printing a bit closer to markdown, with header line, wider separations
between columns and capitalized header fields.
Signed-off-by: Vincent Stehlé's avatarVincent Stehlé <vincent.stehle@arm.com>
parent 27671453
......@@ -504,26 +504,29 @@ def gen_template(cross_check, filename):
def do_print(cross_check, fields):
logging.debug(f'Print (fields: {fields})')
# First pass to find the width for each field except the last one
fm1 = fields[:len(fields) - 1]
# First pass to find the width for each field
w = {}
for f in fm1:
for f in fields:
w[f] = len(f)
for x in cross_check:
for f in fm1:
for f in fields:
w[f] = max(w[f], len(str(x[f]) if f in x else ''))
# Second pass where we print
fm1 = fields[:len(fields) - 1]
lf = fields[len(fields) - 1]
sep = ' '
print(sep.join([
*map(lambda f: f"{f.capitalize():{w[f]}}", fm1),
lf.capitalize()]))
print(' '.join([
*map(lambda f: f"{f:{w[f]}}", fm1),
lf]))
print(sep.join([*map(lambda f: '-' * w[f], fields)]))
for x in cross_check:
print(' '.join([
print(sep.join([
*map(lambda f: f"{x[f] if f in x else '':{w[f]}}", fm1),
x[lf] if lf in x else '']))
......
Markdown is supported
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