Strips off the quotes when showing nested table

When showing a nested table, the current formatting logic preserves the
quote marks when displaying a JSON or sometimes a string. This patch
proposes a change to strip of the quotes so the values are shown in more
consistent way.

Change-Id: Ib4b6cd0e941afee456469e1ce2986c1dddb5134f
This commit is contained in:
tengqm
2015-10-14 03:03:33 -04:00
parent 63b8839741
commit 4aaba26660

View File

@@ -14,7 +14,6 @@
# under the License.
from heatclient.common import template_utils
from oslo_serialization import jsonutils
from oslo_utils import importutils
import prettytable
@@ -54,13 +53,12 @@ def format_nested_dict(d, fields, column_names):
for n in column_names:
pt.align[n] = 'l'
for field in d.keys():
keys = sorted(d.keys())
for field in keys:
value = d[field]
if value is six.string_types:
pt.add_row([field, value])
else:
pt.add_row([field, jsonutils.dumps(value, indent=2,
ensure_ascii=False)])
if not isinstance(value, six.string_types):
value = jsonutils.dumps(value, indent=2, ensure_ascii=False)
pt.add_row([field, value.strip('"')])
return pt.get_string()