perf: wmo_to_russian использует модульную константу _WMO_MAPPING вместо создания dict при каждом вызове
This commit is contained in:
parent
b22b02d65e
commit
49cb1a430b
@ -90,9 +90,7 @@ async def fetch_open_meteo(
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def wmo_to_russian(code: Optional[int]) -> str:
|
_WMO_MAPPING: dict[int, str] = {
|
||||||
"""Перевод WMO weather code в русский."""
|
|
||||||
mapping = {
|
|
||||||
0: "Ясно",
|
0: "Ясно",
|
||||||
1: "Ясно",
|
1: "Ясно",
|
||||||
2: "Переменная облачность",
|
2: "Переменная облачность",
|
||||||
@ -122,7 +120,11 @@ def wmo_to_russian(code: Optional[int]) -> str:
|
|||||||
96: "Гроза с градом",
|
96: "Гроза с градом",
|
||||||
99: "Сильная гроза с градом",
|
99: "Сильная гроза с градом",
|
||||||
}
|
}
|
||||||
return mapping.get(code, "Неизвестно")
|
|
||||||
|
|
||||||
|
def wmo_to_russian(code: Optional[int]) -> str:
|
||||||
|
"""Перевод WMO weather code в русский."""
|
||||||
|
return _WMO_MAPPING.get(code, "Неизвестно")
|
||||||
|
|
||||||
|
|
||||||
_WEATHER_MAPPING = [
|
_WEATHER_MAPPING = [
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user