Project

General

Profile

« Previous | Next » 

Revision 7656

units.py: convert(): Support ranges

View differences:

lib/units.py
64 64
            # can't convert quantity with unknown units
65 65
        else: raise NotImplementedError('Unit conversion not implemented yet')
66 66
    else:
67
        return Quantity(str(format.str2float(quantity.value)*conversion), units)
67
        for try_num in xrange(2):
68
            try:
69
                value = format.str2float(quantity.value)
70
                break
71
            except ValueError: quantity.value = parse_range(quantity.value)[0]
72
        return Quantity(str(value*conversion), units)

Also available in: Unified diff