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 of Unit, which is comparable.

You can compare two Unit instances or you can compare Unit with int, float or any str as long as it can go through the Unit.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

x.__ge__(y) <==> x>=y


x.__gt__(y) <==> x>y


x.__le__(y) <==> x<=y

classmethod parse(s)[source]

parsing only the numbers in the string