From 747740997eae7d8932c5ec00cd54500cde1679cf Mon Sep 17 00:00:00 2001 From: Joseph Date: Mon, 1 Mar 2021 01:41:42 +0100 Subject: [PATCH] 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