summaryrefslogtreecommitdiff
path: root/glanceclient/common/utils.py
diff options
context:
space:
mode:
authorFei Long Wang <flwang@cn.ibm.com>2013-11-15 16:02:46 +0800
committerFei Long Wang <flwang@cn.ibm.com>2014-01-06 20:48:54 +0800
commit336feeb5236d549cde44053dfe1a3693e22cd111 (patch)
tree565be94b1ab972fd3058a0ff41d4aab766dc79f8 /glanceclient/common/utils.py
parent80cf47e229cae248ee9b8cdb8d28d6206f8db3b0 (diff)
downloadpython-glanceclient-336feeb5236d549cde44053dfe1a3693e22cd111.tar.gz
Get better format for long lines with PrettyTable
Based on current implement, the cli output format will be bad if the lines are too long. This issue can be fixed by setting 'max_width'. However, there is a bug against it, see https://code.google.com/p/prettytable/source/browse/trunk/CHANGELOG?r=85 line 3. So the requirements.txt is updated as well. docImpact Fixes bug 1251283 Change-Id: I0d4192ad9d10a3d6d47a8319463a5edb57719a68
Diffstat (limited to 'glanceclient/common/utils.py')
-rw-r--r--glanceclient/common/utils.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/glanceclient/common/utils.py b/glanceclient/common/utils.py
index 3e32763..0120572 100644
--- a/glanceclient/common/utils.py
+++ b/glanceclient/common/utils.py
@@ -119,9 +119,10 @@ def print_list(objs, fields, formatters={}):
print(strutils.safe_encode(pt.get_string()))
-def print_dict(d):
+def print_dict(d, max_column_width=80):
pt = prettytable.PrettyTable(['Property', 'Value'], caching=False)
pt.align = 'l'
+ pt.max_width = max_column_width
[pt.add_row(list(r)) for r in d.iteritems()]
print(strutils.safe_encode(pt.get_string(sortby='Property')))