From 2f18e8ac02ec38156465cdf928818aca92921363 Mon Sep 17 00:00:00 2001 From: Nathaniel Evan Date: Thu, 6 Jan 2022 04:30:32 +0700 Subject: [PATCH] Enables Nerd Font for "Weather:" line with v2d or v2n --- lib/view/line.py | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/lib/view/line.py b/lib/view/line.py index 2a31b70..7bc81ef 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, WEATHER_SYMBOL_PLAIN +from constants import WWO_CODE, WEATHER_SYMBOL, WEATHER_SYMBOL_WI_NIGHT, WEATHER_SYMBOL_WI_DAY, WIND_DIRECTION, WIND_DIRECTION_WI, WEATHER_SYMBOL_WIDTH_VTE, WEATHER_SYMBOL_PLAIN from weather_data import get_weather_data from . import v2 from . import v3 @@ -81,8 +81,21 @@ def render_condition(data, query): """Emoji encoded weather condition (c) """ - weather_condition = WEATHER_SYMBOL[WWO_CODE[data['weatherCode']]] - spaces = " "*(WEATHER_SYMBOL_WIDTH_VTE.get(weather_condition) - 1) + if query.get("view") == "v2n": + weather_condition = WEATHER_SYMBOL_WI_NIGHT.get( + WWO_CODE.get( + data['weatherCode'], "Unknown")) + spaces = " " + elif query.get("view") == "v2d": + weather_condition = WEATHER_SYMBOL_WI_DAY.get( + WWO_CODE.get( + data['weatherCode'], "Unknown")) + spaces = " " + else: + weather_condition = WEATHER_SYMBOL.get( + WWO_CODE.get( + data['weatherCode'], "Unknown")) + spaces = " "*(3 - WEATHER_SYMBOL_WIDTH_VTE.get(weather_condition, 1)) return weather_condition + spaces @@ -170,7 +183,10 @@ def render_wind(data, query): degree = "" if degree: - wind_direction = WIND_DIRECTION[int(((degree+22.5)%360)/45.0)] + if query.get("view") in ["v2n", "v2d"]: + wind_direction = WIND_DIRECTION_WI[int(((degree+22.5)%360)/45.0)] + else: + wind_direction = WIND_DIRECTION[int(((degree+22.5)%360)/45.0)] else: wind_direction = ""