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
This commit is contained in:
@@ -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')))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user