summaryrefslogtreecommitdiffstats
path: root/scripts/automation/trex_control_plane/common/text_opts.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/automation/trex_control_plane/common/text_opts.py')
-rwxr-xr-xscripts/automation/trex_control_plane/common/text_opts.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/scripts/automation/trex_control_plane/common/text_opts.py b/scripts/automation/trex_control_plane/common/text_opts.py
index 30d38d3f..78a0ab1f 100755
--- a/scripts/automation/trex_control_plane/common/text_opts.py
+++ b/scripts/automation/trex_control_plane/common/text_opts.py
@@ -38,15 +38,17 @@ def format_num (size, suffix = "", compact = True, opts = ()):
if compact:
for unit in ['','K','M','G','T','P']:
if abs(size) < 1000.0:
- #txt = "%3.2f %s%s" % (size, unit, suffix)
u = unit
break
size /= 1000.0
if isinstance(size, float):
- txt = "%3.2f %s%s" % (size, u, suffix)
+ txt = "%3.2f" % (size)
else:
- txt = "{:,} {:}{:}".format(size, u, suffix)
+ txt = "{:,}".format(size)
+
+ if u or suffix:
+ txt += " {:}{:}".format(u, suffix)
if isinstance(opts, tuple):
return format_text(txt, *opts)