129 lines
4.5 KiB
Python
129 lines
4.5 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:
|
|||
|
|
lines = f.readlines()
|
|||
|
|
|
|||
|
|
# 处理每一行
|
|||
|
|
output_lines = []
|
|||
|
|
i = 0
|
|||
|
|
while i < len(lines):
|
|||
|
|
line = lines[i]
|
|||
|
|
|
|||
|
|
# 检查是否是position行
|
|||
|
|
if '"position":' in line:
|
|||
|
|
# 提取position名称
|
|||
|
|
import re
|
|||
|
|
match = re.search(r'"position":\s*"([^"]+)"', line)
|
|||
|
|
if match:
|
|||
|
|
position_name = match.group(1)
|
|||
|
|
|
|||
|
|
# 如果是需要更新的岗位
|
|||
|
|
if position_name in positions_to_update:
|
|||
|
|
print(f"\n找到岗位:{position_name}")
|
|||
|
|
|
|||
|
|
# 添加position行
|
|||
|
|
output_lines.append(line)
|
|||
|
|
i += 1
|
|||
|
|
|
|||
|
|
# 查找后续的modified字段
|
|||
|
|
found_modified = False
|
|||
|
|
while i < len(lines):
|
|||
|
|
current_line = lines[i]
|
|||
|
|
|
|||
|
|
if '"modified":' in current_line:
|
|||
|
|
print(f" 更新modified字段")
|
|||
|
|
found_modified = True
|
|||
|
|
|
|||
|
|
# 准备新的modified内容
|
|||
|
|
escaped_content = json.dumps(modified_resumes[position_name], ensure_ascii=False)
|
|||
|
|
|
|||
|
|
# 获取缩进
|
|||
|
|
indent = len(current_line) - len(current_line.lstrip())
|
|||
|
|
spaces = ' ' * indent
|
|||
|
|
|
|||
|
|
# 写入新的modified行
|
|||
|
|
output_lines.append(f'{spaces}"modified": {escaped_content}')
|
|||
|
|
|
|||
|
|
# 跳过原来的modified内容(可能跨多行)
|
|||
|
|
# 查找下一个字段的开始(以引号开头的行)或者对象/数组的结束
|
|||
|
|
i += 1
|
|||
|
|
while i < len(lines):
|
|||
|
|
if (lines[i].strip().startswith('"') or
|
|||
|
|
lines[i].strip().startswith('}') or
|
|||
|
|
lines[i].strip().startswith(']')):
|
|||
|
|
# 如果需要添加逗号
|
|||
|
|
if lines[i].strip().startswith('"'):
|
|||
|
|
output_lines[-1] += ',\n'
|
|||
|
|
elif not output_lines[-1].endswith(',\n'):
|
|||
|
|
output_lines[-1] += '\n'
|
|||
|
|
break
|
|||
|
|
i += 1
|
|||
|
|
break
|
|||
|
|
else:
|
|||
|
|
output_lines.append(current_line)
|
|||
|
|
i += 1
|
|||
|
|
|
|||
|
|
# 如果遇到下一个position或文件结束,停止
|
|||
|
|
if '"position":' in current_line or i >= len(lines):
|
|||
|
|
break
|
|||
|
|
|
|||
|
|
if not found_modified:
|
|||
|
|
print(f" 警告:未找到modified字段")
|
|||
|
|
continue
|
|||
|
|
|
|||
|
|
output_lines.append(line)
|
|||
|
|
i += 1
|
|||
|
|
|
|||
|
|
# 写入更新后的内容
|
|||
|
|
with open(mock_file_path, 'w', encoding='utf-8') as f:
|
|||
|
|
f.writelines(output_lines)
|
|||
|
|
|
|||
|
|
print("\n✅ 所有修改版简历已成功更新!")
|
|||
|
|
print(f"更新了 {len(modified_resumes)} 个岗位的修改版简历")
|
|||
|
|
|
|||
|
|
# 验证语法
|
|||
|
|
import subprocess
|
|||
|
|
result = subprocess.run(['node', '-c', mock_file_path], capture_output=True, text=True)
|
|||
|
|
if result.returncode == 0:
|
|||
|
|
print("✅ JavaScript语法验证通过!")
|
|||
|
|
else:
|
|||
|
|
print("❌ JavaScript语法错误:")
|
|||
|
|
print(result.stderr)
|