MCPcopy Index your code
hub / github.com/pyfa-org/Pyfa / FormatValue

Method FormatValue

gui/builtinItemStatsViews/itemAttributes.py:364–374  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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

Callers 2

GetDataMethod · 0.95
__init__Method · 0.80

Calls 2

formatAmountFunction · 0.90
roundDecFunction · 0.85

Tested by

no test coverage detected