Handle missing labels in generate_report()
This commit is contained in:
parent
95b0d1e3f4
commit
0e5fab0104
1 changed files with 2 additions and 2 deletions
|
|
@ -54,7 +54,7 @@ def generate_report(sensor_data, *temp_labels, colors=True):
|
||||||
_temps.append('{}{}{}'.format(
|
_temps.append('{}{}{}'.format(
|
||||||
_label.lower() if _label != 'Current' else '',
|
_label.lower() if _label != 'Current' else '',
|
||||||
': ' if _label != 'Current' else '',
|
': ' if _label != 'Current' else '',
|
||||||
get_temp_str(_data[_label], colors=colors)))
|
get_temp_str(_data.get(_label, '???'), colors=colors)))
|
||||||
_line += ', '.join(_temps)
|
_line += ', '.join(_temps)
|
||||||
report.append(_line)
|
report.append(_line)
|
||||||
report.append(' ')
|
report.append(' ')
|
||||||
|
|
@ -147,7 +147,7 @@ def get_temp_str(temp, colors=True):
|
||||||
try:
|
try:
|
||||||
temp = float(temp)
|
temp = float(temp)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return '{}°C'.format(temp)
|
return '{}'.format(temp)
|
||||||
else:
|
else:
|
||||||
return '{}{:2.0f}°C'.format(
|
return '{}{:2.0f}°C'.format(
|
||||||
'-' if temp < 0 else '',
|
'-' if temp < 0 else '',
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue