From 01ca31ae916d73b08151efdddc80b77610842f16 Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Wed, 10 Oct 2007 15:06:21 +0000 Subject: [PATCH] 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 --- lib/cli.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/cli.py b/lib/cli.py index 85606d40a..d1b6925ec 100644 --- a/lib/cli.py +++ b/lib/cli.py @@ -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: format_fields.append("%s") elif field in numfields: @@ -501,6 +504,7 @@ def GenerateTable(headers, fields, separator, data, pass else: val = row[idx] = utils.FormatUnit(val) + val = row[idx] = str(val) if separator is None: mlens[idx] = max(mlens[idx], len(val)) -- GitLab