46 lines
1.4 KiB
Python
46 lines
1.4 KiB
Python
"""
|
||
任务二专用的智能表格API模块
|
||
继承自任务一的 SmartSheetAPI,使用任务二专用的日志记录器
|
||
|
||
设计说明:
|
||
- 继承 src.smartsheet.SmartSheetAPI 的所有功能
|
||
- 重写 __init__ 方法,使用 get_task2_logger() 替代 get_logger()
|
||
- 确保所有智能表格 API 调用日志写入 logs2/ 目录
|
||
"""
|
||
|
||
import sys
|
||
from pathlib import Path
|
||
|
||
# 将项目根目录添加到 Python 路径
|
||
project_root = Path(__file__).parent.parent
|
||
sys.path.insert(0, str(project_root))
|
||
|
||
from src.smartsheet import SmartSheetAPI
|
||
from src2.logger import get_task2_logger
|
||
|
||
|
||
class SmartSheetAPITask2(SmartSheetAPI):
|
||
"""任务二专用的智能表格API类"""
|
||
|
||
def __init__(self, access_token: str, docid: str, test_mode: bool = False):
|
||
"""
|
||
初始化智能表格API(任务二专用)
|
||
|
||
Args:
|
||
access_token: 企业微信access_token
|
||
docid: 智能表格文档ID
|
||
test_mode: 是否启用测试模式(显示API返回结果)
|
||
"""
|
||
# 调用父类初始化
|
||
super().__init__(access_token, docid, test_mode)
|
||
|
||
# 替换为任务二专用的日志记录器
|
||
self.logger = get_task2_logger()
|
||
|
||
|
||
if __name__ == "__main__":
|
||
print("=== 任务二智能表格API模块 ===\n")
|
||
print("此模块继承自 src.smartsheet.SmartSheetAPI")
|
||
print("使用任务二专用的日志记录器,日志写入 logs2/ 目录")
|
||
print("\n请通过 SmartSheetSync 类使用此模块")
|