- Switch from wttr.in + Open-Meteo fallback to Yandex Weather API - Add YANDEX_WEATHER_API_KEY to .env and config validation - Enrich weather output: wind gusts, wind direction (Russian) - Pressure now in mmHg directly from Yandex (no conversion needed) - Update rate limiter: weather_limiter + open_meteo_limiter → yandex_weather_limiter - Remove dead code: API_URL_WEATHER, fetch_open_meteo, translate_weather - Update all tests (271 passed)
55 lines
1.2 KiB
Python
55 lines
1.2 KiB
Python
from .pogoda import (
|
|
_session as _weather_session,
|
|
fetch_weather,
|
|
format_weather_data_for_console,
|
|
format_weather_for_message,
|
|
pressure_to_mmhg,
|
|
wmo_to_russian,
|
|
yandex_condition_to_russian,
|
|
)
|
|
from .news import ( # noqa: E402
|
|
_session as _news_session,
|
|
RSS_URL_ARTICLES,
|
|
RSS_URL_POSTS,
|
|
fetch_rss,
|
|
format_articles,
|
|
truncate_title,
|
|
)
|
|
from .cat import ( # noqa: E402
|
|
_session as _cat_session,
|
|
fetch_cat,
|
|
)
|
|
|
|
__all__ = [
|
|
# Погода
|
|
"fetch_weather",
|
|
"format_weather_data_for_console",
|
|
"format_weather_for_message",
|
|
"pressure_to_mmhg",
|
|
"wmo_to_russian",
|
|
"yandex_condition_to_russian",
|
|
# Новости
|
|
"RSS_URL_ARTICLES",
|
|
"RSS_URL_POSTS",
|
|
"fetch_rss",
|
|
"format_articles",
|
|
"truncate_title",
|
|
# Котики
|
|
"fetch_cat",
|
|
# Lifecycle
|
|
"close_all_sessions",
|
|
]
|
|
|
|
|
|
def close_all_sessions() -> None:
|
|
"""Закрыть все requests.Session для освобождения сокетов."""
|
|
for session in (
|
|
_weather_session,
|
|
_news_session,
|
|
_cat_session,
|
|
):
|
|
try:
|
|
session.close()
|
|
except Exception:
|
|
pass # Cleanup — игнорируем ошибки
|