diff options
| author | John Herndon <john.herndon@hp.com> | 2014-01-16 09:48:59 -0700 |
|---|---|---|
| committer | John Herndon <john.herndon@hp.com> | 2014-01-24 10:39:05 -0700 |
| commit | deb34163afbb2ac7e00c74613812b3bea413a807 (patch) | |
| tree | ffa3dfd89d53c1f00aa46a42ce3738f5fbaa2fc5 /ceilometerclient/common/utils.py | |
| parent | c634f71b22b52f9030c0b42419b97535fdee5c90 (diff) | |
| download | python-ceilometerclient-deb34163afbb2ac7e00c74613812b3bea413a807.tar.gz | |
Update client to display data type of traits
fixes bug 1268032
Change-Id: I47dfd3208fb3f7e5e5e2b33bd9b00c688d8283cd
Diffstat (limited to 'ceilometerclient/common/utils.py')
| -rw-r--r-- | ceilometerclient/common/utils.py | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/ceilometerclient/common/utils.py b/ceilometerclient/common/utils.py index 4f532e5..d466a19 100644 --- a/ceilometerclient/common/utils.py +++ b/ceilometerclient/common/utils.py @@ -66,18 +66,20 @@ def print_list(objs, fields, field_labels, formatters={}, sortby=0): sortby_index=sortby) -def nested_dict_formatter(field): +def nested_list_of_dict_formatter(field, column_names): # (TMaddox) Because the formatting scheme actually drops the whole object # into the formatter, rather than just the specified field, we have to # extract it and then pass the value. - return lambda o: format_nested_dict(getattr(o, field)) + return lambda o: format_nested_list_of_dict(getattr(o, field), + column_names) -def format_nested_dict(d): +def format_nested_list_of_dict(l, column_names): pt = prettytable.PrettyTable(caching=False, print_empty=False, - header=False, hrules=prettytable.FRAME) - for k, v in six.iteritems(d): - pt.add_row([k, format_nested_dict(v) if isinstance(v, dict) else v]) + header=True, hrules=prettytable.FRAME, + field_names=column_names) + for d in l: + pt.add_row(map(lambda k: d[k], column_names)) return pt.get_string() |
