| """Veri işleme modülü. | |
| NOTE: | |
| This package historically included Streamlit-first modules (UI-oriented) and | |
| API-ready modules (Streamlit-free). Importing Streamlit-dependent modules at | |
| package import time breaks headless/API use-cases. | |
| To keep both worlds working, we guard optional imports here. | |
| """ | |
| from __future__ import annotations | |
| from typing import Any, Callable, Optional | |
| def _optional(importer: Callable[[], Any], name: str) -> Optional[Any]: | |
| try: | |
| return importer() | |
| except Exception: | |
| return None | |
| get_stock_data = _optional(lambda: __import__("data.stock_data", fromlist=["get_stock_data"]).get_stock_data, "get_stock_data") | |
| get_stock_news = _optional(lambda: __import__("data.news_data", fromlist=["get_stock_news"]).get_stock_news, "get_stock_news") | |
| get_general_market_news = _optional( | |
| lambda: __import__("data.news_data", fromlist=["get_general_market_news"]).get_general_market_news, | |
| "get_general_market_news", | |
| ) | |
| analyze_news_with_gemini = _optional( | |
| lambda: __import__("data.news_data", fromlist=["analyze_news_with_gemini"]).analyze_news_with_gemini, | |
| "analyze_news_with_gemini", | |
| ) | |
| save_analysis_result = _optional( | |
| lambda: __import__("data.utils", fromlist=["save_analysis_result"]).save_analysis_result, | |
| "save_analysis_result", | |
| ) | |
| get_analysis_result = _optional( | |
| lambda: __import__("data.utils", fromlist=["get_analysis_result"]).get_analysis_result, | |
| "get_analysis_result", | |
| ) | |
| get_announcements = _optional( | |
| lambda: __import__("data.announcements", fromlist=["get_announcements"]).get_announcements, | |
| "get_announcements", | |
| ) | |
| __all__ = [ | |
| "get_stock_data", | |
| "get_stock_news", | |
| "get_general_market_news", | |
| "analyze_news_with_gemini", | |
| "save_analysis_result", | |
| "get_analysis_result", | |
| "get_announcements", | |
| ] |