mirror of
https://github.com/chubin/wttr.in
synced 2024-11-15 08:37:12 +00:00
Add new function: render_condition_plain
This commit is contained in:
parent
747740997e
commit
edd1e1e3dd
1 changed files with 12 additions and 5 deletions
|
@ -77,13 +77,10 @@ def render_feel_like_temperature(data, query):
|
|||
|
||||
return temperature
|
||||
|
||||
def render_condition(data, query, plain=False):
|
||||
def render_condition(data, query):
|
||||
"""Emoji encoded weather condition (c)
|
||||
"""
|
||||
|
||||
if plain:
|
||||
weather_condition = WEATHER_SYMBOL_PLAIN[WWO_CODE[data['weatherCode']]]
|
||||
else:
|
||||
weather_condition = WEATHER_SYMBOL[WWO_CODE[data['weatherCode']]]
|
||||
spaces = " "*(WEATHER_SYMBOL_WIDTH_VTE.get(weather_condition) - 1)
|
||||
|
||||
|
@ -109,6 +106,15 @@ def render_condition_fullname(data, query):
|
|||
|
||||
return weather_condition
|
||||
|
||||
def render_condition_plain(data, query):
|
||||
"""Plain text weather condition (x)
|
||||
"""
|
||||
|
||||
weather_condition = WEATHER_SYMBOL_PLAIN[WWO_CODE[data['weatherCode']]]
|
||||
spaces = " "*(WEATHER_SYMBOL_WIDTH_VTE.get(weather_condition) - 1)
|
||||
|
||||
return weather_condition + spaces
|
||||
|
||||
def render_humidity(data, query):
|
||||
"""
|
||||
humidity (h)
|
||||
|
@ -252,6 +258,7 @@ def render_local_timezone(data, query, local_time_of):
|
|||
FORMAT_SYMBOL = {
|
||||
'c': render_condition,
|
||||
'C': render_condition_fullname,
|
||||
'x': render_condition_plain,
|
||||
'h': render_humidity,
|
||||
't': render_temperature,
|
||||
'f': render_feel_like_temperature,
|
||||
|
|
Loading…
Reference in a new issue