Add protection against passed None values

Had a problem with this when teting deep core mining lasers on Skiff
This commit is contained in:
DarkPhoenix
2010-11-06 20:51:08 +03:00
parent 1790a4c5f0
commit 5574df241a

13
util.py
View File

@@ -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):