Consisent abbreviation of size units
Most units (KB, MB, GB, TB, PB) are shown in an abbreviated format. The exception were bytes, which where shown as "Bytes". This commit resolves this inconsistency by showing "B" for byte units. Change-Id: Ied94c777a70bf8955f5a328ffcb63d98a7a2befd Closes-Bug: 1411595 Signed-off-by: Iago Estrela <hiagoestrelas@gmail.com>
This commit is contained in:
parent
a9d83dda1c
commit
ae7896cea5
@ -48,15 +48,15 @@ def filesizeformat(bytes, filesize_number_format):
|
||||
try:
|
||||
bytes = float(bytes)
|
||||
except (TypeError, ValueError, UnicodeDecodeError):
|
||||
return ungettext_lazy("%(size)d Byte",
|
||||
"%(size)d Bytes", 0) % {'size': 0}
|
||||
return ungettext_lazy("%(size)d B",
|
||||
"%(size)d B", 0) % {'size': 0}
|
||||
|
||||
if bytes == float('inf'):
|
||||
return _('Infinity')
|
||||
if bytes < units.Ki:
|
||||
bytes = int(bytes)
|
||||
return ungettext_lazy("%(size)d Byte",
|
||||
"%(size)d Bytes", bytes) % {'size': bytes}
|
||||
return ungettext_lazy("%(size)d B",
|
||||
"%(size)d B", bytes) % {'size': bytes}
|
||||
if bytes < units.Mi:
|
||||
return _("%s KB") % filesize_number_format(bytes / units.Ki)
|
||||
if bytes < units.Gi:
|
||||
@ -79,7 +79,7 @@ def float_cast_filesizeformat(value, multiplier=1, format=int_format):
|
||||
value = float(value)
|
||||
value = filesizeformat(value * multiplier, format).replace(' ', '')
|
||||
except (TypeError, ValueError):
|
||||
value = value or _('0 Bytes')
|
||||
value = value or _('0 B')
|
||||
return value
|
||||
|
||||
|
||||
|
@ -63,7 +63,7 @@ class TemplateTagTests(test.TestCase):
|
||||
size_str = ('5|diskgbformat', '10|diskgbformat',
|
||||
'5555|mb_float_format', '80|mb_float_format',
|
||||
'.5|mbformat', '0.005|mbformat', '0.0005|mbformat')
|
||||
expected = ' 5GB 10GB 5.4GB 80MB 512KB 5KB 524Bytes '
|
||||
expected = ' 5GB 10GB 5.4GB 80MB 512KB 5KB 524B '
|
||||
|
||||
text = ''
|
||||
for size_filter in size_str:
|
||||
|
@ -63,7 +63,7 @@ class UpdateDefaultVolumeQuotas(UpdateDefaultQuotas):
|
||||
|
||||
def get_compute_quota_name(quota):
|
||||
QUOTA_NAMES = {
|
||||
'injected_file_content_bytes': _('Injected File Content Bytes'),
|
||||
'injected_file_content_bytes': _('Injected File Content (B)'),
|
||||
'injected_file_path_bytes': _('Length of Injected File Path'),
|
||||
'metadata_items': _('Metadata Items'),
|
||||
'cores': _('VCPUs'),
|
||||
|
@ -42,7 +42,7 @@ class UpdateDefaultComputeQuotasAction(workflows.Action):
|
||||
label=_("Injected Files"))
|
||||
injected_file_content_bytes = forms.IntegerField(
|
||||
min_value=-1,
|
||||
label=_("Injected File Content Bytes"))
|
||||
label=_("Injected File Content (B)"))
|
||||
injected_file_path_bytes = forms.IntegerField(
|
||||
min_value=-1,
|
||||
label=_("Length of Injected File Path"))
|
||||
|
@ -108,7 +108,7 @@ class ComputeQuotaAction(CommonQuotaAction):
|
||||
label=_("Injected Files"))
|
||||
injected_file_content_bytes = forms.IntegerField(
|
||||
min_value=-1,
|
||||
label=_("Injected File Content (Bytes)"))
|
||||
label=_("Injected File Content (B)"))
|
||||
injected_file_path_bytes = forms.IntegerField(
|
||||
min_value=-1,
|
||||
label=_("Length of Injected File Path"))
|
||||
|
@ -288,7 +288,7 @@ class UsageViewTests(test.TestCase):
|
||||
self.assertEqual(10000, chart_ram['quota'])
|
||||
self.assertEqual('9.8GB', chart_ram['quota_display'])
|
||||
self.assertEqual(0, chart_ram['used'])
|
||||
self.assertEqual('0Bytes', chart_ram['used_display'])
|
||||
self.assertEqual('0B', chart_ram['used_display'])
|
||||
|
||||
volume_charts = [c for c in charts if c['title'] == 'Volume'][0]
|
||||
chart_gigabytes = [c for c in volume_charts['charts']
|
||||
@ -297,7 +297,7 @@ class UsageViewTests(test.TestCase):
|
||||
self.assertEqual(1000, chart_gigabytes['quota'])
|
||||
self.assertEqual('1000GB', chart_gigabytes['quota_display'])
|
||||
self.assertEqual(0, chart_gigabytes['used'])
|
||||
self.assertEqual('0Bytes', chart_gigabytes['used_display'])
|
||||
self.assertEqual('0B', chart_gigabytes['used_display'])
|
||||
|
||||
network_charts = [c for c in charts if c['title'] == 'Network'][0]
|
||||
chart_fip = [c for c in network_charts['charts']
|
||||
|
@ -57,7 +57,7 @@ class DefaultsPage(basepage.BaseNavigationPage):
|
||||
QUOTAS_TABLE_LIMIT_COLUMN = 'Limit'
|
||||
VOLUMES_TAB_INDEX = 1
|
||||
DEFAULT_COMPUTE_QUOTA_NAMES = [
|
||||
'Injected File Content Bytes',
|
||||
'Injected File Content (B)',
|
||||
'Metadata Items',
|
||||
'Server Group Members',
|
||||
'Server Groups',
|
||||
|
@ -96,10 +96,10 @@ QUOTA_NAMES = {
|
||||
"cores": _('VCPUs'),
|
||||
"instances": _('Instances'),
|
||||
"injected_files": _('Injected Files'),
|
||||
"injected_file_content_bytes": _('Injected File Content Bytes'),
|
||||
"injected_file_content_bytes": _('Injected File Content (B)'),
|
||||
"ram": _('RAM (MB)'),
|
||||
"key_pairs": _('Key Pairs'),
|
||||
"injected_file_path_bytes": _('Injected File Path Bytes'),
|
||||
"injected_file_path_bytes": _('Injected File Path (B)'),
|
||||
# cinder
|
||||
"volumes": _('Volumes'),
|
||||
"snapshots": _('Volume Snapshots'),
|
||||
|
Loading…
x
Reference in New Issue
Block a user