@register.filter(name='format_bigint')
def format_bigint(value):
  try:
    value = int(value)
  except (TypeError, ValueError):
    return value

  if value < 1024*1024:
    return value

  K = 1024
  formaters = (
    (2, '%.2fM'),
    (3, '%.2fG'),
    (4, '%.2fT'),
    (5, '%.2fP'),
  )

  for exponent, formater in formaters:
    larger_num = K ** exponent
    if value < larger_num * K:
      return formater % (float(larger_num)/value)

# is space quota healthy
dataset/ETHPy150Open XiaoMi/minos/owl/monitor/templatetags/extended_filter.py/format_bigint/swapped operands of `/`