cfme.utils.units module¶
-
class
cfme.utils.units.
Unit
(number, prefix, unit_type)[source]¶ Bases:
object
This class serves for simple comparison of numbers that have units.
Imagine you pull a text value from the UI. 2 GB. By doing
Unit.parse('2 GB')
you get an instance ofUnit
, which is comparable.You can compare two
Unit
instances or you can compareUnit
withint
,float
or anystr
as long as it can go through theUnit.parse()
.If you compare
Unit
only (or a string that gets subsequently parsed), it also takes the kind of the unit it is, you cannot compare bytes with hertzes. It then calculates the absolute value in the base units and that gets compared.If you compare with a number, it does it like it was the number of the same unit. So eg. doing:
Unit.parse('2 GB') == 2 *1024 * 1024 * 1024 `` is True
-
absolute
¶
-
number
¶
-
prefix
¶
-
unit_type
¶
-