Merge pull request #583 from hejops/master

Plain text weather symbols
This commit is contained in:
Igor Chubin 2021-03-15 14:32:23 +01:00 committed by GitHub
commit dd8626a50b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 1 deletions

View File

@ -147,6 +147,28 @@ WEATHER_SYMBOL_WI_NIGHT = {
"VeryCloudy": "",
}
WEATHER_SYMBOL_PLAIN = {
"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 = {
}

View File

@ -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
@ -106,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)
@ -249,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,