This commit is contained in:
2025-09-10 13:50:18 +08:00
parent a19db36b7d
commit 3009beeb3d
6 changed files with 355 additions and 211 deletions

40
Config/BaseConfig.py Normal file
View File

@@ -0,0 +1,40 @@
import os
from datetime import datetime
class BaseConfig:
def __init__(self):
# 基础路径配置
self.root_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
self.data_dir = os.path.join(self.root_dir, 'Data')
self.excel_path = os.path.join(self.root_dir, 'Doc', '数据库-2015-2024-v2.xlsx')
self.json_output_suffix = '.json'
self.start_row = 5 # 有效数据起始行
# 年份范围配置
self.years = [str(year) for year in range(2015, 2025)]
# 教育阶段通用配置
self.education_stages = {
'preschool': '学前教育',
'primary': '小学教育',
'junior': '初中教育',
'senior': '高中教育',
'vocational': '中职教育'
}
def get_output_path(self, filename):
"""获取JSON输出路径"""
return os.path.join(self.data_dir, f'{filename}{self.json_output_suffix}')
def get_log_path(self):
"""获取日志文件路径"""
log_dir = os.path.join(self.root_dir, 'Log')
os.makedirs(log_dir, exist_ok=True)
return os.path.join(log_dir, f'{datetime.now().strftime("%Y%m%d")}.log')
# 工作表名称配置
SHEET_NAMES = {
'population': '人口', # 修改为实际名称
'enrollment_rate': '毛入学率', # 其他工作表名称
'school_count': '学校数'
}