Image show: print human readable string when the virtual size is unknown

Currently, when the virtual size of an image is not known, "None" is displayed.
To a regular user, it feels like a programming error. We try and make things
clearer by using a "human readable" string instead.

Change-Id: Id7b8799356857d9bc58cc8a3677024fe1a7f4f56
Partial-Bug: #1665037
This commit is contained in:
Cyril Roelandt
2018-05-03 15:54:00 +02:00
parent 1ef5e5d169
commit abfe0f4bf3
2 changed files with 40 additions and 0 deletions
+2
View File
@@ -421,6 +421,8 @@ def print_image(image_obj, human_readable=False, max_col_width=None):
ignore = ['self', 'access', 'file', 'schema']
image = dict([item for item in image_obj.items()
if item[0] not in ignore])
if 'virtual_size' in image:
image['virtual_size'] = image.get('virtual_size') or 'Not available'
if human_readable:
image['size'] = make_size_human_readable(image['size'])
if str(max_col_width).isdigit():