Prints '-' instead of 'None' when data is None

Client prints 'None' when data is None , and client also prints
'None' when data is a string 'None'. But string 'None' is  different
to None. To clear the confusion, Client should print '-' instead of
'None' when data is None. Nova Client and Cinder Client has cleared
the confusion.

Change-Id: I5b7013eb7ccfb99658702066191feed93f82fb8a
Related-Bug: #1600553
Closed-Bug: #1422244
This commit is contained in:
PanFengyun 2016-07-10 19:08:02 +08:00
parent f0c2a168c6
commit 11b49d6c97

@ -170,15 +170,18 @@ def print_list(objs, fields, formatters=None, sortby_index=0,
for o in objs:
row = []
for field in fields:
data = '-'
if field in formatters:
row.append(formatters[field](o))
data = formatters[field](o)
else:
if field in mixed_case_fields:
field_name = field.replace(' ', '_')
else:
field_name = field.lower().replace(' ', '_')
data = getattr(o, field_name, '')
row.append(data)
if data is None:
data = '-'
row.append(data)
pt.add_row(row)
if six.PY3:
@ -227,8 +230,12 @@ def print_dict(dct, dict_property="Property", wrap=0):
col1 = ''
elif isinstance(v, list):
val = str([str(i) for i in v])
if val is None:
val = '-'
pt.add_row([k, val])
else:
if v is None:
v = '-'
pt.add_row([k, v])
if six.PY3: