TrendRadar/trendradar/storage/__init__.py
2025-12-13 13:44:35 +08:00

45 lines
1.1 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# coding=utf-8
"""
存储模块 - 支持多种存储后端
支持的存储后端:
- local: 本地 SQLite + TXT/HTML 文件
- remote: 远程云存储S3 兼容协议R2/OSS/COS/S3 等)
- auto: 根据环境自动选择GitHub Actions 用 remote其他用 local
"""
from trendradar.storage.base import (
StorageBackend,
NewsItem,
NewsData,
convert_crawl_results_to_news_data,
convert_news_data_to_results,
)
from trendradar.storage.local import LocalStorageBackend
from trendradar.storage.manager import StorageManager, get_storage_manager
# 远程后端可选导入(需要 boto3
try:
from trendradar.storage.remote import RemoteStorageBackend
HAS_REMOTE = True
except ImportError:
RemoteStorageBackend = None
HAS_REMOTE = False
__all__ = [
# 基础类
"StorageBackend",
"NewsItem",
"NewsData",
# 转换函数
"convert_crawl_results_to_news_data",
"convert_news_data_to_results",
# 后端实现
"LocalStorageBackend",
"RemoteStorageBackend",
"HAS_REMOTE",
# 管理器
"StorageManager",
"get_storage_manager",
]