Ejemplo n.º 1
0
 def FormatValue(value, unit, rounding='prec', digits=3):
     """Formats a value / unit combination into a string
     @todo: move this to a more central location, since this is also used in the item mutator panel"""
     if isinstance(value, (int, float)) and rounding == 'prec':
         fvalue = formatAmount(value, digits, 0, 0)
     elif isinstance(value, (int, float)) and rounding == 'dec':
         fvalue = roundDec(value, digits)
     else:
         fvalue = value
     return "%s %s" % (fvalue, unit)
Ejemplo n.º 2
0
 def FormatValue(value, unit, rounding='prec', digits=3):
     """Formats a value / unit combination into a string
     @todo: move this to a more central location, since this is also used in the item mutator panel"""
     if isinstance(value, (int, float)) and rounding == 'prec':
         fvalue = formatAmount(value, digits, 0, 0)
     elif isinstance(value, (int, float)) and rounding == 'dec':
         fvalue = roundDec(value, digits)
     else:
         fvalue = value
     return "%s %s" % (fvalue, unit)
Ejemplo n.º 3
0
 def FormatValue(value, unit, rounding='prec', digits=3):
     """Formats a value / unit combination into a string
     @todo: move this to a more central location, since this is also used in the item mutator panel"""
     if isinstance(value, (int, float)) and rounding == 'prec':
         fvalue = formatAmount(value, digits, 0, 0)
     elif isinstance(value, (int, float)) and rounding == 'dec':
         fvalue = roundDec(value, digits)
     else:
         fvalue = value
     unitSuffix = f' {unit}' if unit is not None else ''
     return f'{fvalue}{unitSuffix}'