Merge pull request #692 from nathanielevan/master

Make "Weather:" line use Nerd Fonts with v2d/v2n, and fix v2d to use day icons
This commit is contained in:
Igor Chubin 2022-01-16 18:09:09 +01:00 committed by GitHub
commit 8bdc54bb70
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 5 deletions

View file

@ -25,7 +25,7 @@ from astral.sun import sun
import pytz 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 weather_data import get_weather_data
from . import v2 from . import v2
from . import v3 from . import v3
@ -81,8 +81,21 @@ def render_condition(data, query):
"""Emoji encoded weather condition (c) """Emoji encoded weather condition (c)
""" """
weather_condition = WEATHER_SYMBOL[WWO_CODE[data['weatherCode']]] if query.get("view") == "v2n":
spaces = " "*(WEATHER_SYMBOL_WIDTH_VTE.get(weather_condition) - 1) 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 return weather_condition + spaces
@ -170,6 +183,9 @@ def render_wind(data, query):
degree = "" degree = ""
if degree: if degree:
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)] wind_direction = WIND_DIRECTION[int(((degree+22.5)%360)/45.0)]
else: else:
wind_direction = "" wind_direction = ""

View file

@ -321,7 +321,7 @@ def draw_emoji(data, config):
weather_symbol = constants.WEATHER_SYMBOL_WI_NIGHT weather_symbol = constants.WEATHER_SYMBOL_WI_NIGHT
weather_symbol_width_vte = constants.WEATHER_SYMBOL_WIDTH_VTE_WI weather_symbol_width_vte = constants.WEATHER_SYMBOL_WIDTH_VTE_WI
elif config.get("view") == "v2d": elif config.get("view") == "v2d":
weather_symbol = constants.WEATHER_SYMBOL_WI_NIGHT weather_symbol = constants.WEATHER_SYMBOL_WI_DAY
weather_symbol_width_vte = constants.WEATHER_SYMBOL_WIDTH_VTE_WI weather_symbol_width_vte = constants.WEATHER_SYMBOL_WIDTH_VTE_WI
else: else:
weather_symbol = constants.WEATHER_SYMBOL weather_symbol = constants.WEATHER_SYMBOL