diff options
author | Vincent Untz <vuntz@suse.com> | 2012-06-26 11:08:24 +0200 |
---|---|---|
committer | Vincent Untz <vuntz@suse.com> | 2012-06-26 11:36:21 +0200 |
commit | 3813abcf20fa5451c2df8b1b3f252e6b5a3bf6f4 (patch) | |
tree | c0ff5b3f6d398653bfb87b069f2a3ff72c1eb080 | |
parent | 44a1ee32e29825257cac5c0a61fc3be51b79eb65 (diff) | |
download | python-keystoneclient-3813abcf20fa5451c2df8b1b3f252e6b5a3bf6f4.tar.gz |
Do not display None in pretty tables for fields with no value
Fields that are present but unset in a backend (like the email field for
a user created with no email in the KVS backend with the keystone
command line) will appear as "None" when listed, instead of as an empty
field.
Change-Id: I86dc0a204847518e61ba9f6f46d4637d897cfac1
-rw-r--r-- | keystoneclient/utils.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/keystoneclient/utils.py b/keystoneclient/utils.py index fa27902..863f03e 100644 --- a/keystoneclient/utils.py +++ b/keystoneclient/utils.py @@ -31,6 +31,8 @@ def print_list(objs, fields, formatters={}): else: field_name = field.lower().replace(' ', '_') data = getattr(o, field_name, '') + if data is None: + data = '' row.append(data) pt.add_row(row) @@ -40,7 +42,10 @@ def print_list(objs, fields, formatters={}): def print_dict(d): pt = prettytable.PrettyTable(['Property', 'Value'], caching=False) pt.aligns = ['l', 'l'] - [pt.add_row(list(r)) for r in d.iteritems()] + for (prop, value) in d.iteritems(): + if value is None: + value = '' + pt.add_row((prop, value)) print pt.get_string(sortby='Property') |