Files
online_sys/frontend_大健康/fix_resume_structure.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

50 lines
1.7 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
# 读取文件
with open('src/mocks/resumeInterviewMock.js', 'r', encoding='utf-8') as f:
content = f.read()
# 查找有问题的结构:在 ], 后面直接跟着 compound_skills: [
# 这种结构破坏了JSON格式需要删除
pattern = r'(\s*\]\s*,)\s*compound_skills:\s*\[[^\]]*?\],\s*personal_summary:\s*"[^"]*?"\s*\}\s*\}\s*\],\s*("(?:新媒体运营|文旅产品设计|品牌运营|旅游)":\s*\[)'
def fix_structure(match):
# 保留第一个 ], 和后面正确的行业开始
return match.group(1) + '\n ' + match.group(2)
# 使用更精确的模式
# 匹配露营地运营后面的多余部分
pattern1 = r'( \}\s*\}\s*\],)\s*compound_skills:\s*\[[^\]]*?\],\s*personal_summary:\s*"[^"]*?"\s*\}\s*\}\s*\],\s*("新媒体运营":\s*\[)'
content = re.sub(pattern1, r'\1\n \2', content)
# 查找并修复其他类似的问题
# 匹配任何在 }] 后面跟着 compound_skills 的情况
pattern2 = r'(\}\s*\]\s*,)\s*compound_skills:\s*\[[^\[]*?\],\s*(?="[^"]+":)'
count = 0
while True:
new_content = re.sub(pattern2, r'\1\n ', content)
if new_content == content:
break
content = new_content
count += 1
print(f"修复了第 {count} 处问题")
# 写回文件
with open('src/mocks/resumeInterviewMock.js', 'w', encoding='utf-8') as f:
f.write(content)
print(f"✅ 修复完成,共修复了 {count} 处结构问题")
# 验证文件语法
import subprocess
result = subprocess.run(['node', '-c', 'src/mocks/resumeInterviewMock.js'],
capture_output=True, text=True)
if result.returncode == 0:
print("✅ 文件语法验证通过")
else:
print(f"❌ 文件仍有语法错误:\n{result.stderr}")