Files
online_sys/frontend_智能开发/fix_modified_versions.py
KQL a7242f0c69 Initial commit: 教务系统在线平台
- 包含4个产业方向的前端项目:智能开发、智能制造、大健康、财经商贸
- 已清理node_modules、.yoyo等大文件,项目大小从2.6GB优化至631MB
- 配置完善的.gitignore文件

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-12 18:16:55 +08:00

184 lines
5.8 KiB
Python
Raw Permalink 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 re
from datetime import datetime
def create_backup(file_path):
"""创建备份文件"""
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
backup_path = f"{file_path}.backup_{timestamp}"
with open(file_path, 'r', encoding='utf-8') as f:
content = f.read()
with open(backup_path, 'w', encoding='utf-8') as f:
f.write(content)
print(f"已创建备份: {backup_path}")
return backup_path
def find_all_positions_with_modified():
"""查找所有有modified字段的岗位"""
file_path = 'src/mocks/resumeInterviewMock.js'
with open(file_path, 'r', encoding='utf-8') as f:
lines = f.readlines()
positions_with_modified = []
for i, line in enumerate(lines):
if 'modified:' in line and '`' in line:
# 向上查找最近的position定义
for j in range(i-1, max(0, i-50), -1):
if 'position:' in lines[j] and '"' in lines[j]:
# 提取岗位名称
match = re.search(r'position:\s*"([^"]+)"', lines[j])
if match:
position_name = match.group(1)
positions_with_modified.append({
'name': position_name,
'position_line': j + 1,
'modified_line': i + 1
})
break
return positions_with_modified
def remove_modified_for_positions():
"""删除指定岗位的modified字段"""
file_path = 'src/mocks/resumeInterviewMock.js'
# 创建备份
create_backup(file_path)
# 有真实修改版的岗位列表这些要保留modified
real_modified_positions = [
"会展策划师",
"会展执行助理",
"会展讲解员",
"活动策划师",
"活动执行",
"漫展策划师",
"旅游规划师",
"旅游计调专员",
"景区运营专员",
"文旅运营总监助理"
]
# 读取文件内容
with open(file_path, 'r', encoding='utf-8') as f:
content = f.read()
# 查找所有有modified的岗位
positions = find_all_positions_with_modified()
print("\n找到的所有有modified字段的岗位")
for pos in positions:
status = "保留" if pos['name'] in real_modified_positions else "删除"
print(f" [{status}] {pos['name']} (行 {pos['position_line']} -> {pos['modified_line']})")
# 处理每个需要删除modified的岗位
positions_to_remove = [p for p in positions if p['name'] not in real_modified_positions]
# 从后往前处理,避免行号变化影响
positions_to_remove.sort(key=lambda x: x['modified_line'], reverse=True)
lines = content.split('\n')
for pos in positions_to_remove:
print(f"\n处理 {pos['name']}...")
# 找到modified字段的起始和结束位置
modified_line_idx = pos['modified_line'] - 1
# 找到modified字段的开始包括可能的逗号
start_idx = modified_line_idx
# 向前查找逗号
for i in range(modified_line_idx - 1, max(0, modified_line_idx - 5), -1):
if ',' in lines[i]:
start_idx = i
break
# 找到modified字段的结束找到闭合的反引号
end_idx = modified_line_idx
in_template = False
for i in range(modified_line_idx, min(len(lines), modified_line_idx + 1000)):
if '`' in lines[i]:
if not in_template and 'modified:' in lines[i]:
in_template = True
elif in_template:
end_idx = i
break
# 删除这些行
print(f" 删除行 {start_idx + 1}{end_idx + 1}")
del lines[start_idx:end_idx + 1]
# 保存文件
new_content = '\n'.join(lines)
with open(file_path, 'w', encoding='utf-8') as f:
f.write(new_content)
print(f"\n已删除 {len(positions_to_remove)} 个岗位的modified字段")
def verify_final_state():
"""验证最终状态"""
positions = find_all_positions_with_modified()
print("\n" + "=" * 50)
print("最终验证结果:")
print(f"还有modified字段的岗位{len(positions)}个):")
real_modified_positions = [
"会展策划师",
"会展执行助理",
"会展讲解员",
"活动策划师",
"活动执行",
"漫展策划师",
"旅游规划师",
"旅游计调专员",
"景区运营专员",
"文旅运营总监助理"
]
# 分类显示
correct = []
incorrect = []
for pos in positions:
if pos['name'] in real_modified_positions:
correct.append(pos['name'])
else:
incorrect.append(pos['name'])
if correct:
print("\n✓ 正确保留的岗位:")
for name in correct:
print(f" - {name}")
if incorrect:
print("\n✗ 不应该有modified的岗位需要手动处理")
for name in incorrect:
print(f" - {name}")
# 检查是否有遗漏
missing = []
for name in real_modified_positions:
if name not in [p['name'] for p in positions]:
missing.append(name)
if missing:
print("\n⚠️ 应该有modified但没找到的岗位")
for name in missing:
print(f" - {name}")
def main():
print("开始处理没有真实修改版的岗位...")
print("=" * 50)
# 删除假的修改版
remove_modified_for_positions()
# 验证结果
verify_final_state()
if __name__ == "__main__":
main()