Commit 01ca31ae authored by Iustin Pop's avatar Iustin Pop
Browse files

Some small fixes to utils.GenerateTable

This adds:
  - fix the case when a dumb caller didn't stringify its values
  - explicitly raise a ProgrammerError in case a field is missing from
    the headers dictionary

Reviewed-by: imsnah
parent 3023170f
......@@ -479,6 +479,9 @@ def GenerateTable(headers, fields, separator, data,
format_fields = []
for field in fields:
if headers and field not in headers:
raise errors.ProgrammerError("Missing header description for field '%s'"
% field)
if separator is not None:
elif field in numfields:
......@@ -501,6 +504,7 @@ def GenerateTable(headers, fields, separator, data,
val = row[idx] = utils.FormatUnit(val)
val = row[idx] = str(val)
if separator is None:
mlens[idx] = max(mlens[idx], len(val))
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