Files
ALL-teach_sys/frontend_能源/update_modified_resumes.py
KQL cd2e307402 初始化12个产业教务系统项目
主要内容:
- 包含12个产业的完整教务系统前端代码
- 智能启动脚本 (start-industry.sh)
- 可视化产业导航页面 (index.html)
- 项目文档 (README.md)

优化内容:
- 删除所有node_modules和.yoyo文件夹,从7.5GB减少到2.7GB
- 添加.gitignore文件避免上传不必要的文件
- 自动依赖管理和智能启动系统

产业列表:
1. 文旅产业 (5150)
2. 智能制造 (5151)
3. 智能开发 (5152)
4. 财经商贸 (5153)
5. 视觉设计 (5154)
6. 交通物流 (5155)
7. 大健康 (5156)
8. 土木水利 (5157)
9. 食品产业 (5158)
10. 化工产业 (5159)
11. 能源产业 (5160)
12. 环保产业 (5161)

🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-24 14:14:14 +08:00

125 lines
4.5 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.

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import json
import os
import datetime
import shutil
def read_modified_resumes():
"""读取所有修改版简历文件"""
modified_resumes = {}
folder_path = "网页未导入数据/能源产业/能源修改版简历"
# 获取所有.md文件
for filename in os.listdir(folder_path):
if filename.endswith('.md'):
position_name = filename.replace('.md', '')
file_path = os.path.join(folder_path, filename)
with open(file_path, 'r', encoding='utf-8') as f:
content = f.read()
modified_resumes[position_name] = content
return modified_resumes
def update_mock_file_with_modified():
"""更新Mock文件添加修改版简历内容"""
mock_file = "src/mocks/resumeInterviewMock.js"
# 备份文件
backup_path = f"{mock_file}.backup_{datetime.datetime.now().strftime('%Y%m%d_%H%M%S')}"
shutil.copy(mock_file, backup_path)
print(f"✅ 已备份文件到:{backup_path}")
# 读取修改版简历
modified_resumes = read_modified_resumes()
print(f"📚 找到 {len(modified_resumes)} 个修改版简历文件")
# 读取当前mock文件
with open(mock_file, 'r', encoding='utf-8') as f:
content = f.read()
# 更新resumeTemplates中对应岗位的modified字段
import re
updated_count = 0
for position_name, resume_content in modified_resumes.items():
print(f" 处理岗位: {position_name}")
# 转义特殊字符用于正则表达式
escaped_position = re.escape(position_name)
# 查找该岗位在resumeTemplates中的位置
# 模式:查找 "position": "岗位名称" 后的 content 对象
pattern = rf'("position":\s*"{escaped_position}"[^{{]*?"content":\s*{{[^}}]*?"original":[^,]*?,)(\s*"modified":\s*)"[^"]*"'
# 准备替换的内容转义JSON字符串
escaped_content = json.dumps(resume_content, ensure_ascii=False)
# 执行替换
new_content, count = re.subn(
pattern,
rf'\1\2{escaped_content}',
content
)
if count > 0:
content = new_content
updated_count += 1
print(f" ✅ 已更新")
else:
# 如果第一种模式失败尝试另一种模式没有modified字段的情况
pattern2 = rf'("position":\s*"{escaped_position}"[^{{]*?"content":\s*{{[^}}]*?"original":[^}}]*?)(}})'
# 添加modified字段
replacement = rf'\1,\n "modified": {escaped_content}\2'
new_content, count = re.subn(pattern2, replacement, content)
if count > 0:
content = new_content
updated_count += 1
print(f" ✅ 已添加modified字段")
else:
print(f" ⚠️ 未找到匹配位置")
# 写回文件
with open(mock_file, 'w', encoding='utf-8') as f:
f.write(content)
print(f"\n✅ 成功更新 {updated_count}/{len(modified_resumes)} 个岗位的修改版简历")
# 验证更新
verify_updates(mock_file, modified_resumes.keys())
def verify_updates(mock_file, position_names):
"""验证更新是否成功"""
with open(mock_file, 'r', encoding='utf-8') as f:
content = f.read()
print("\n📊 验证结果:")
for position_name in position_names:
# 检查是否包含该岗位的modified内容
pattern = f'"position": "{position_name}"'
if pattern in content:
# 进一步检查是否有modified字段
# 查找该岗位后面的modified字段
start_idx = content.find(pattern)
if start_idx > 0:
# 查找该岗位content对象的范围简化检查
end_idx = content.find('"position":', start_idx + len(pattern))
if end_idx < 0:
end_idx = start_idx + 2000 # 如果是最后一个取后面2000字符
section = content[start_idx:end_idx]
if '"modified":' in section and position_name in section:
print(f"{position_name}: 已包含修改版")
else:
print(f"{position_name}: 未包含修改版")
else:
print(f" ⚠️ {position_name}: 未找到该岗位")
if __name__ == "__main__":
update_mock_file_with_modified()