new option: C (Weather condition textual name)

This commit is contained in:
Igor Chubin 2019-04-23 16:44:41 +02:00
parent 5901e711f6
commit 83b1fd45f2
2 changed files with 22 additions and 0 deletions

View file

@ -142,6 +142,7 @@ To specify your own custom output format, use the special `%`-notation:
```
c Weather condition,
C Weather condition textual name,
h Humidity,
t Temperature,
w Wind,

View file

@ -59,6 +59,26 @@ def render_condition(data, query):
weather_condition = WEATHER_SYMBOL[WWO_CODE[data['weatherCode']]]
return weather_condition
def render_condition_fullname(data, query):
"""
condition_fullname (C)
"""
found = None
for key, val in data.items():
if key.startswith('lang_'):
found = val
break
if not found:
found = data['weatherDesc']
try:
weather_condition = found[0]['value']
except KeyError:
weather_condition = ''
return weather_condition
def render_humidity(data, query):
"""
humidity (h)
@ -138,6 +158,7 @@ def render_sunset(data, query):
FORMAT_SYMBOL = {
'c': render_condition,
'C': render_condition_fullname,
'h': render_humidity,
't': render_temperature,
'w': render_wind,