def _image_show(image, human_readable=False, max_column_width=80): # Flatten image properties dict for display info = copy.deepcopy(image._info) if human_readable: info['size'] = utils.make_size_human_readable(info['size']) for (k, v) in six.iteritems(info.pop('properties')): info['Property \'%s\'' % k] = v utils.print_dict(info, max_column_width=max_column_width)
def _image_show(image, human_readable=False, max_column_width=80): # Flatten image properties dict for display info = copy.deepcopy(image._info) if human_readable: info["size"] = utils.make_size_human_readable(info["size"]) for (k, v) in six.iteritems(info.pop("properties")): info["Property '%s'" % k] = v utils.print_dict(info, max_column_width=max_column_width)
def _image_show(image, human_readable=False): # Flatten image properties dict for display info = copy.deepcopy(image._info) if human_readable: info['size'] = utils.make_size_human_readable(info['size']) for (k, v) in info.pop('properties').iteritems(): info['Property \'%s\'' % k] = v utils.print_dict(info)
def test_make_size_human_readable(self): self.assertEqual("106B", utils.make_size_human_readable(106)) self.assertEqual("1000kB", utils.make_size_human_readable(1024000)) self.assertEqual("1MB", utils.make_size_human_readable(1048576)) self.assertEqual("1.4GB", utils.make_size_human_readable(1476395008)) self.assertEqual("9.3MB", utils.make_size_human_readable(9761280)) self.assertEqual("0B", utils.make_size_human_readable(None))
def convert_size(image): image.size = utils.make_size_human_readable(image.size) return image