mirror of
https://github.com/chubin/wttr.in
synced 2024-12-25 03:13:06 +00:00
new option: C (Weather condition textual name)
This commit is contained in:
parent
5901e711f6
commit
83b1fd45f2
2 changed files with 22 additions and 0 deletions
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue