diff options
author | liyingjun <yingjun.li@kylin-cloud.com> | 2015-07-21 12:50:14 +0800 |
---|---|---|
committer | liyingjun <yingjun.li@kylin-cloud.com> | 2015-08-03 11:14:44 +0800 |
commit | 2ec9a2251d1faa8a167e975bccbaa2e59137e47d (patch) | |
tree | df46e89e322f773735a878611ed6ca278e514cad /cinderclient/utils.py | |
parent | a0f13ea8f1b7e5269f73e2175ace03347090f345 (diff) | |
download | python-cinderclient-2ec9a2251d1faa8a167e975bccbaa2e59137e47d.tar.gz |
Fixes table when there are multiline in result data
The table doesn't display right when there are multiple line in
result data. Fixes this by replace "\r" with " ".
Change-Id: I0b994466f3c65ea973e80d9f03ca9a248147d49d
Closes-bug: #1476462
Diffstat (limited to 'cinderclient/utils.py')
-rw-r--r-- | cinderclient/utils.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/cinderclient/utils.py b/cinderclient/utils.py index 896c646..89478bd 100644 --- a/cinderclient/utils.py +++ b/cinderclient/utils.py @@ -141,6 +141,8 @@ def print_list(objs, fields, formatters=None, sortby_index=0): data = getattr(o, field_name, '') if data is None: data = '-' + if isinstance(data, six.string_types) and "\r" in data: + data = data.replace("\r", " ") row.append(data) pt.add_row(row) @@ -154,7 +156,11 @@ def print_list(objs, fields, formatters=None, sortby_index=0): def print_dict(d, property="Property"): pt = prettytable.PrettyTable([property, 'Value'], caching=False) pt.aligns = ['l', 'l'] - [pt.add_row(list(r)) for r in six.iteritems(d)] + for r in six.iteritems(d): + r = list(r) + if isinstance(r[1], six.string_types) and "\r" in r[1]: + r[1] = r[1].replace("\r", " ") + pt.add_row(r) _print(pt, property) |