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
(value, unit, rounding='prec', digits=3)
| 362 | |
| 363 | @staticmethod |
| 364 | def FormatValue(value, unit, rounding='prec', digits=3): |
| 365 | """Formats a value / unit combination into a string |
| 366 | @todo: move this to a more central location, since this is also used in the item mutator panel""" |
| 367 | if isinstance(value, (int, float)) and rounding == 'prec': |
| 368 | fvalue = formatAmount(value, digits, 0, 0) |
| 369 | elif isinstance(value, (int, float)) and rounding == 'dec': |
| 370 | fvalue = roundDec(value, digits) |
| 371 | else: |
| 372 | fvalue = value |
| 373 | unitSuffix = f' {unit}' if unit is not None else '' |
| 374 | return f'{fvalue}{unitSuffix}' |
| 375 |
no test coverage detected