Exemplo n.º 1
0
 def create_unit_hint(cls, from_unit, to_unit):
     converted_value = convert(from_unit, 1, to_unit)
     if converted_value.magnitude > 0.001:
         value = format_quantity(converted_value)
         return TextHint(text='{} is {}'.format(format_value(from_unit, 1), value))
     else:
         converted_value = convert(to_unit, 1, from_unit)
         value = format_quantity(converted_value)
         return TextHint(text='{} is {}'.format(format_value(to_unit, 1), value))
Exemplo n.º 2
0
 def get_task(obj):
     return "Convert {} to {}".format(format_value(obj.from_unit, obj.from_value), format_unit(obj.to_unit))