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

This commit is contained in:
Jenkins 2016-07-20 09:03:44 +00:00 committed by Gerrit Code Review
commit 03c933e369

View File

@ -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: