Files
ALL-teach_sys/frontend_能源/safe_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

115 lines
4.3 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
import re
def read_modified_resumes():
"""读取所有修改版简历文件"""
modified_resumes = {}
folder_path = "网页未导入数据/能源产业/能源修改版简历"
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_safely():
"""安全地更新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部分
templates_match = re.search(r'const resumeTemplates = ({[\s\S]*?});', content)
if not templates_match:
print("❌ 未找到resumeTemplates")
return
templates_str = templates_match.group(1)
# 安全地解析为Python对象
# 由于可能有已存在的modified字段需要先清理
try:
# 使用正则表达式提取各个岗位群
templates = {}
# 匹配每个岗位群
group_pattern = r'"([^"]+)":\s*\[([\s\S]*?)\](?=,\s*"|\s*})'
for match in re.finditer(group_pattern, templates_str):
group_name = match.group(1)
group_content = match.group(2)
# 解析该岗位群的模板
templates[group_name] = []
# 匹配每个岗位模板
position_pattern = r'{\s*"position":\s*"([^"]+)"[^}]*?"content":\s*{[^}]*?"original":\s*"([^"\\]*(?:\\.[^"\\]*)*)"[^}]*?}[^}]*?}'
for pos_match in re.finditer(position_pattern, group_content):
position_name = pos_match.group(1)
original_content = pos_match.group(2)
template_obj = {
"position": position_name,
"content": {
"original": original_content,
"modified": ""
}
}
# 查找修改版简历
if position_name in modified_resumes:
template_obj["content"]["modified"] = modified_resumes[position_name]
print(f" ✅ 匹配到: {position_name}")
elif position_name.replace('PACK', 'pack') in modified_resumes:
# 处理大小写问题
template_obj["content"]["modified"] = modified_resumes[position_name.replace('PACK', 'pack')]
print(f" ✅ 匹配到: {position_name} (大小写转换)")
elif position_name.replace('pack', 'PACK') in modified_resumes:
template_obj["content"]["modified"] = modified_resumes[position_name.replace('pack', 'PACK')]
print(f" ✅ 匹配到: {position_name} (大小写转换)")
templates[group_name].append(template_obj)
# 重新生成resumeTemplates
new_templates_str = json.dumps(templates, ensure_ascii=False, indent=2)
# 替换原来的resumeTemplates
new_content = content[:templates_match.start(1)] + new_templates_str + content[templates_match.end(1):]
# 写回文件
with open(mock_file, 'w', encoding='utf-8') as f:
f.write(new_content)
print("\n✅ 成功更新Mock文件")
except Exception as e:
print(f"❌ 更新失败: {e}")
# 恢复备份
shutil.copy(backup_path, mock_file)
print("已恢复备份")
if __name__ == "__main__":
update_mock_safely()