Add protection against passed None values
Had a problem with this when teting deep core mining lasers on Skiff
This commit is contained in:
13
util.py
13
util.py
@@ -10,11 +10,14 @@ def formatAmount(val, prec=3, lowest=0, highest=0):
|
||||
lowest -- lowest order for suffixizing
|
||||
highest -- highest order for suffixizing
|
||||
"""
|
||||
# Separate value to mantissa and suffix
|
||||
mantissa, suffix = suffixizeAmount(val, lowest, highest)
|
||||
# Round mantissa and add suffix
|
||||
newMantissa = processAmount(mantissa, prec)
|
||||
result = u"{0}{1}".format(newMantissa, suffix)
|
||||
if val is None:
|
||||
result = ""
|
||||
else:
|
||||
# Separate value to mantissa and suffix
|
||||
mantissa, suffix = suffixizeAmount(val, lowest, highest)
|
||||
# Round mantissa and add suffix
|
||||
newMantissa = processAmount(mantissa, prec)
|
||||
result = u"{0}{1}".format(newMantissa, suffix)
|
||||
return result
|
||||
|
||||
def suffixizeAmount(val, lowest=-6, highest=9):
|
||||
|
||||
Reference in New Issue
Block a user