106 lines
3.7 KiB
Python
106 lines
3.7 KiB
Python
|
|
#!/usr/bin/env python3
|
|||
|
|
# -*- coding: utf-8 -*-
|
|||
|
|
|
|||
|
|
import os
|
|||
|
|
import json
|
|||
|
|
|
|||
|
|
# 修改版简历文件夹路径
|
|||
|
|
modified_resume_dir = "/Users/apple/Documents/cursor/教务系统/frontend_大健康/网页未导入数据/大健康产业/大健康修改版简历"
|
|||
|
|
|
|||
|
|
# 需要处理的10个岗位
|
|||
|
|
positions_to_update = [
|
|||
|
|
"健康顾问",
|
|||
|
|
"心理咨询师",
|
|||
|
|
"运动康复师",
|
|||
|
|
"体检医生",
|
|||
|
|
"微整形医生",
|
|||
|
|
"皮肤美容医生",
|
|||
|
|
"康复治疗师",
|
|||
|
|
"营养师助理",
|
|||
|
|
"健康管理师助理",
|
|||
|
|
"老年健康照护师"
|
|||
|
|
]
|
|||
|
|
|
|||
|
|
# 读取修改版简历内容
|
|||
|
|
modified_resumes = {}
|
|||
|
|
for position in positions_to_update:
|
|||
|
|
file_path = os.path.join(modified_resume_dir, f"{position}.md")
|
|||
|
|
if os.path.exists(file_path):
|
|||
|
|
with open(file_path, 'r', encoding='utf-8') as f:
|
|||
|
|
# 读取内容并跳过第一行(标题)
|
|||
|
|
lines = f.readlines()
|
|||
|
|
# 从第3行开始(跳过标题和空行)
|
|||
|
|
content = ''.join(lines[2:]) # 跳过标题行和空行
|
|||
|
|
modified_resumes[position] = content.strip()
|
|||
|
|
print(f"✓ 读取修改版简历:{position}")
|
|||
|
|
else:
|
|||
|
|
print(f"✗ 文件不存在:{file_path}")
|
|||
|
|
|
|||
|
|
# 读取当前的resumeInterviewMock.js
|
|||
|
|
mock_file_path = "src/mocks/resumeInterviewMock.js"
|
|||
|
|
with open(mock_file_path, 'r', encoding='utf-8') as f:
|
|||
|
|
content = f.read()
|
|||
|
|
|
|||
|
|
# 查找resumeTemplates的开始和结束位置
|
|||
|
|
templates_start = content.find("const resumeTemplates = {")
|
|||
|
|
templates_end = content.find("};", templates_start) + 2
|
|||
|
|
|
|||
|
|
if templates_start == -1 or templates_end == -1:
|
|||
|
|
print("错误:找不到resumeTemplates定义")
|
|||
|
|
exit(1)
|
|||
|
|
|
|||
|
|
# 提取resumeTemplates部分
|
|||
|
|
templates_section = content[templates_start:templates_end]
|
|||
|
|
|
|||
|
|
# 为每个岗位更新modified字段
|
|||
|
|
for position, modified_content in modified_resumes.items():
|
|||
|
|
print(f"\n更新岗位:{position}")
|
|||
|
|
|
|||
|
|
# 查找该岗位的content对象
|
|||
|
|
position_pattern = f'"position": "{position}"'
|
|||
|
|
pos = templates_section.find(position_pattern)
|
|||
|
|
|
|||
|
|
if pos == -1:
|
|||
|
|
print(f" 警告:找不到岗位 {position}")
|
|||
|
|
continue
|
|||
|
|
|
|||
|
|
# 找到该岗位的content对象
|
|||
|
|
content_start = templates_section.find('"content": {', pos)
|
|||
|
|
if content_start == -1:
|
|||
|
|
print(f" 警告:找不到岗位 {position} 的content字段")
|
|||
|
|
continue
|
|||
|
|
|
|||
|
|
# 找到modified字段的开始位置
|
|||
|
|
modified_start = templates_section.find('"modified":', content_start)
|
|||
|
|
if modified_start == -1:
|
|||
|
|
print(f" 警告:找不到岗位 {position} 的modified字段")
|
|||
|
|
continue
|
|||
|
|
|
|||
|
|
# 找到modified字段值的开始(跳过 "modified": 和空格)
|
|||
|
|
value_start = templates_section.find('"', modified_start + len('"modified":'))
|
|||
|
|
|
|||
|
|
# 找到modified字段值的结束(找到对应的结束引号)
|
|||
|
|
# 需要处理转义的引号
|
|||
|
|
value_end = value_start + 1
|
|||
|
|
while value_end < len(templates_section):
|
|||
|
|
if templates_section[value_end] == '"' and templates_section[value_end-1] != '\\':
|
|||
|
|
break
|
|||
|
|
value_end += 1
|
|||
|
|
|
|||
|
|
# 替换modified字段的值
|
|||
|
|
escaped_content = json.dumps(modified_content, ensure_ascii=False)
|
|||
|
|
new_modified = f'"modified": {escaped_content}'
|
|||
|
|
old_modified = templates_section[modified_start:value_end+1]
|
|||
|
|
|
|||
|
|
templates_section = templates_section.replace(old_modified, new_modified)
|
|||
|
|
print(f" ✓ 已更新modified字段")
|
|||
|
|
|
|||
|
|
# 重新组合完整文件内容
|
|||
|
|
new_content = content[:templates_start] + templates_section + content[templates_end:]
|
|||
|
|
|
|||
|
|
# 写入更新后的内容
|
|||
|
|
with open(mock_file_path, 'w', encoding='utf-8') as f:
|
|||
|
|
f.write(new_content)
|
|||
|
|
|
|||
|
|
print("\n✅ 所有修改版简历已成功更新!")
|
|||
|
|
print(f"更新了 {len(modified_resumes)} 个岗位的修改版简历")
|