[modules/weather] Small improvements

This commit is contained in:
tobi-wan-kenobi 2020-04-04 07:47:53 +02:00
parent a7effbff78
commit a71828f0b4
4 changed files with 21 additions and 21 deletions

View file

@ -23,6 +23,13 @@ def aslist(val):
return val
return str(val).replace(' ', '').split(',')
__UNITS = {
'metric': 'C', 'kelvin': 'K', 'imperial': 'F',
'default': 'C'
}
def astemperature(value, unit='metric'):
return u'{}°{}'.format(int(value), __UNITS.get(unit, __UNITS['default']))
def byte(val, fmt='{:.2f}'):
for unit in ['', 'Ki', 'Mi', 'Gi']:
if val < 1024.0: