Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"""For a given row from the table, format it (i.e. floating
points and color if applicable.
"""
value = row[key]
if not isinstance(value, Number):
return value
# determine if integer value
is_integer = float(value).is_integer()
template = '{}' if is_integer else '{:' + self.floatfmt + '}'
# if numeric, there could be a 'best' key
key_best = key + '_best'
if (key_best in row) and row[key_best]:
template = color + template + Ansi.ENDC.value
return template.format(value)
value = row[key]
if isinstance(value, bool) or value is None:
return '+' if value else ''
if not isinstance(value, Number):
return value
# determine if integer value
is_integer = float(value).is_integer()
template = '{}' if is_integer else '{:' + self.floatfmt + '}'
# if numeric, there could be a 'best' key
key_best = key + '_best'
if (key_best in row) and row[key_best]:
template = color + template + Ansi.ENDC.value
return template.format(value)
"""For a given row from the table, format it (i.e. floating
points and color if applicable.
"""
value = row[key]
if not isinstance(value, Number):
return value
# determine if integer value
is_integer = float(value).is_integer()
template = '{}' if is_integer else '{:' + self.floatfmt + '}'
# if numeric, there could be a 'best' key
key_best = key + '_best'
if (key_best in row) and row[key_best]:
template = color + template + Ansi.ENDC.value
return template.format(value)
def _yield_keys_formatted(self, row):
colors = cycle([color.value for color in Ansi if color != color.ENDC])
color = next(colors)
for key in self._sorted_keys(row.keys()):
formatted = self.format_row(row, key, color=color)
yield key, formatted
color = next(colors)
def _yield_keys_formatted(self, row):
colors = cycle([color.value for color in Ansi if color != color.ENDC])
for key, color in zip(self._sorted_keys(row.keys()), colors):
formatted = self.format_row(row, key, color=color)
if key.startswith('event_'):
key = key[6:]
yield key, formatted
def _yield_keys_formatted(self, row):
colors = cycle([color.value for color in Ansi if color != color.ENDC])
color = next(colors)
for key in self._sorted_keys(row.keys()):
formatted = self.format_row(row, key, color=color)
yield key, formatted
color = next(colors)