[modules/weather] Small improvements
This commit is contained in:
parent
a7effbff78
commit
a71828f0b4
4 changed files with 21 additions and 21 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue