From cbae22a11f20e117afe2922ba4a89a3e7662a693 Mon Sep 17 00:00:00 2001 From: Joseph Date: Mon, 1 Mar 2021 01:27:56 +0100 Subject: [PATCH 1/3] Add plaintext weather symbols --- lib/constants.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/lib/constants.py b/lib/constants.py index 649cd08..2b4cab1 100644 --- a/lib/constants.py +++ b/lib/constants.py @@ -147,6 +147,29 @@ WEATHER_SYMBOL_WI_NIGHT = { "VeryCloudy": "", } +# https://github.com/chubin/wttr.in/issues/270#issue-409067058 +WEATHER_SYMBOL_TEXT = { + "Unknown": "?", + "Cloudy": "mm", + "Fog": "=", + "HeavyRain": "///", + "HeavyShowers": "//", + "HeavySnow": "**", + "HeavySnowShowers": "*/*", + "LightRain": "/", + "LightShowers": ".", + "LightSleet": "x", + "LightSleetShowers": "x/", + "LightSnow": "*", + "LightSnowShowers": "*/", + "PartlyCloudy": "m", + "Sunny": "o", + "ThunderyHeavyRain": "/!/", + "ThunderyShowers": "", + "ThunderySnowShowers": "*!*", + "VeryCloudy": "mmm", +} + WEATHER_SYMBOL_WIDTH_VTE_WI = { } From 747740997eae7d8932c5ec00cd54500cde1679cf Mon Sep 17 00:00:00 2001 From: Joseph Date: Mon, 1 Mar 2021 01:41:42 +0100 Subject: [PATCH 2/3] Add optional argument 'plain' to render_condition --- lib/constants.py | 5 ++--- lib/view/line.py | 9 ++++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/constants.py b/lib/constants.py index 2b4cab1..11e28af 100644 --- a/lib/constants.py +++ b/lib/constants.py @@ -147,8 +147,7 @@ WEATHER_SYMBOL_WI_NIGHT = { "VeryCloudy": "", } -# https://github.com/chubin/wttr.in/issues/270#issue-409067058 -WEATHER_SYMBOL_TEXT = { +WEATHER_SYMBOL_PLAIN = { "Unknown": "?", "Cloudy": "mm", "Fog": "=", @@ -165,7 +164,7 @@ WEATHER_SYMBOL_TEXT = { "PartlyCloudy": "m", "Sunny": "o", "ThunderyHeavyRain": "/!/", - "ThunderyShowers": "", + "ThunderyShowers": "!/", "ThunderySnowShowers": "*!*", "VeryCloudy": "mmm", } diff --git a/lib/view/line.py b/lib/view/line.py index 361d396..b48571d 100644 --- a/lib/view/line.py +++ b/lib/view/line.py @@ -25,7 +25,7 @@ from astral.sun import sun import pytz -from constants import WWO_CODE, WEATHER_SYMBOL, WIND_DIRECTION, WEATHER_SYMBOL_WIDTH_VTE +from constants import WWO_CODE, WEATHER_SYMBOL, WIND_DIRECTION, WEATHER_SYMBOL_WIDTH_VTE, WEATHER_SYMBOL_PLAIN from weather_data import get_weather_data from . import v2 from . import v3 @@ -77,11 +77,14 @@ def render_feel_like_temperature(data, query): return temperature -def render_condition(data, query): +def render_condition(data, query, plain=False): """Emoji encoded weather condition (c) """ - weather_condition = WEATHER_SYMBOL[WWO_CODE[data['weatherCode']]] + 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) return weather_condition + spaces From edd1e1e3dd9ee3a5932f56bc53fbbb54a2c45191 Mon Sep 17 00:00:00 2001 From: Joseph Date: Mon, 1 Mar 2021 01:58:37 +0100 Subject: [PATCH 3/3] Add new function: render_condition_plain --- lib/view/line.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/view/line.py b/lib/view/line.py index b48571d..221c96c 100644 --- a/lib/view/line.py +++ b/lib/view/line.py @@ -77,14 +77,11 @@ 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']]] + weather_condition = WEATHER_SYMBOL[WWO_CODE[data['weatherCode']]] spaces = " "*(WEATHER_SYMBOL_WIDTH_VTE.get(weather_condition) - 1) return weather_condition + spaces @@ -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,