Added convert_to_gbps Method

Signed-off-by: jitendracandela <jitendra.kushavah@candelatech.com>
This commit is contained in:
jitendracandela
2024-07-12 10:55:57 +05:30
parent 9aeaf82450
commit bd9ac610f4

View File

@@ -1874,8 +1874,19 @@ class lf_libs:
else:
return False
def convert_to_gbps(self, value="1Mbps"):
""" Convert values to Gbps """
number = int(''.join([char for char in value if char.isdigit()]))
unit = ''.join([char for char in value if char.isalpha()])
unit = unit.lower()
if unit == 'gbps':
return number
elif unit == 'mbps':
return number / 1000
elif unit == 'kbps':
return number / 1000000
else:
raise ValueError("Unknown unit")
class Report: