summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavanum Srinivas <davanum@gmail.com>2015-11-12 14:08:50 -0500
committerDavanum Srinivas <davanum@gmail.com>2015-11-12 14:11:57 -0500
commitd01a8cbac73842066bb129fc807bea3bc3a7278f (patch)
tree746532ead53011cd2d320339ed48fb33ee12374e
parentb97ef58628a824851ef07e4c0429723b08424214 (diff)
downloadpython-ceilometerclient-d01a8cbac73842066bb129fc807bea3bc3a7278f.tar.gz
Last sync from oslo-incubator2.0.1
oslo-incubator will cease to host common code soon. This is hopefully the very last sync from oslo-incubator. Change-Id: I5adf01a6db61f34c1699c52c08cd47c4edccd8fd
-rw-r--r--ceilometerclient/openstack/common/cliutils.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/ceilometerclient/openstack/common/cliutils.py b/ceilometerclient/openstack/common/cliutils.py
index 326aab5..643faf1 100644
--- a/ceilometerclient/openstack/common/cliutils.py
+++ b/ceilometerclient/openstack/common/cliutils.py
@@ -140,7 +140,7 @@ def isunauthenticated(func):
def print_list(objs, fields, formatters=None, sortby_index=0,
mixed_case_fields=None, field_labels=None):
- """Print a list or objects as a table, one row per object.
+ """Print a list of objects as a table, one row per object.
:param objs: iterable of :class:`Resource`
:param fields: attributes that correspond to columns, in order
@@ -186,16 +186,17 @@ def print_list(objs, fields, formatters=None, sortby_index=0,
print(encodeutils.safe_encode(pt.get_string(**kwargs)))
-def print_dict(dct, dict_property="Property", wrap=0):
+def print_dict(dct, dict_property="Property", wrap=0, dict_value='Value'):
"""Print a `dict` as a table of two columns.
:param dct: `dict` to print
:param dict_property: name of the first column
:param wrap: wrapping for the second column
+ :param dict_value: header label for the value (second) column
"""
- pt = prettytable.PrettyTable([dict_property, 'Value'])
+ pt = prettytable.PrettyTable([dict_property, dict_value])
pt.align = 'l'
- for k, v in six.iteritems(dct):
+ for k, v in sorted(dct.items()):
# convert dict to str to check length
if isinstance(v, dict):
v = six.text_type(v)